apache rewritecond on dynamic ip address

Posted on

apache rewritecond on dynamic ip address – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about apache-2.2, dynamic-ip, , , .

I’d like to restrict access to a certain set of pages by IP address (there are only 2 or 3 people allowed to access this area). Unfortunately, at least one of those is a dynamically allocated IP address from an ISP. One very long-winded option I’ve considered is a kind of custom dyndns-type setup where the client would register their IP change, which would then rewrite the apache config file and reload it. Given that we have a dyndns account set up, we can always get their current IP address from there and periodically update / reload the apache config file. But is there a more elegant way?

Here’s the current line (with dummy ip):

RewriteCond %{REMOTE_ADDR} !^12.23.34.45

and I’ve also tried:

RewriteCond %{REMOTE_HOST} !^name.dtdns.net

which was a long shot anyway – their IP address would never resolve back to that name, obviously. I don’t have access to mod_perl on this server, so can’t do anything there. Is there another way?

Solution :

What you’re using is IP-based authentication. Nothing wrong with that, I’ve used it, although always in combination with other authentication methods. But if the IP address is changing, I don’t think there’s any shortcut to updating the Apache config whenever the address changes, as you described.

An alternative is to use user/password authentication, or client certificate-based authentication with SSL.

Leave a Reply

Your email address will not be published.