Reputation: 117
I have a cloud-based apache2 web server, which serves multiple sites using various virtualhost conf files.
One of the websites is for my development only, and is currently configured to only allow my current IP address.
Order deny,allow
Deny from all
Allow from 1.2.4.5
However my IP changes once a week or so - so I'd prefer to use my dynamic DNS hostname. Alas this...
Allow from abc.ddns.net
... does not work. Can it be done?
Upvotes: 2
Views: 3911
Reputation: 1326
There is a new directive, added in Apache2 version 2.4.19
, which does exactly what you want.
Try to use this instead:
Require forward-dns abc.ddns.net
within your virthost definition.
More about this directive can be found on official website - https://httpd.apache.org/docs/2.4/mod/mod_authz_host.html#requiredirectives.
PS: Do not forget to reload/restart your apache2 service.
Upvotes: 0
Reputation: 336
It can work, but it requires your DNS to be setup perfectly. If you use allow from {hostname}
then for each relevant URI path, Apache requests a reverse DNS lookup of the IP for the connection, and then if that returns the correct host name from your allow directive Apache then rechecks that that name resolves to the IP of the original connection.
This is all a relatively expensive set of operations and is normally not recommended. Allow from {ip address}
would normally be preferred.
Upvotes: 5