Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to set a special configuration in our apache web server. I would like to display sites to the users according to their IP addresses.

We plan to upgrade our web sites. During the upgrade we'll put a maintenance site: so all the users which will connect to our web sites will get this site.

There are 200 websites affected by the upgrade, so I don't want to change apache settings for each one.

In order to test the upgrade i need to set apache to let only my IP address to access to asked site. If my IP address is a.b.c.d and if i ask for test.com i want to see it. but all other users, having a different IP address, should get the maintenane site even if they look for test.com.

Our webserver is hosted out of the office (ovh.com france). The testers are the developers at our office and me. We can take some sites and enable them for test in which we implement IP restrictions in each website: the idea is on these websites, if the visitor's IP address is different from our office IP address we redirect this visitor to our maintenance website else we display the website.

Is there a way to do this?

Thank you.

share|improve this question
    
What will I do is configure a new Vhost in apache, in (let's say) port 81, that points to the "new" upgraded site. In the final upgrade pahre, change the 80 vhost to the maintenance website, and check the new web upgraded on port 81 without problems. –  Carlos Dec 21 '10 at 11:32
    
Take a look at mod_rewrite –  topdog Dec 21 '10 at 11:32

3 Answers 3

I think you may find that for testing a new version of the site using a separate vhost for the new version of the site, and use a different ServerName directive (e.g. testing.yourdomain.com) will give you more flexibility than doing something clever with IP addresses. Then when ready to go live, you can just change the ServerName to the live servername.

However, being able to serve different content for different IP addresses is a useful thing to do, especially if you want to test out the performance of different versions of the site with different visitors, or serve content based on geolocation derived from the IP address.

If that is what you want, then you can ignore my answer. But if you only need to give a small number of people access to the test site until it is done, keep it as simple as you can.

share|improve this answer
    
I already thought about what you said, but i have more than 200 websites. changing them will take me more time. thats my i'm looking for a specific apache configuration to make me things easy.I'm not planning to use geolocation. just to avoid for our visitors to see some bugs (if there will be) on our websites once the upgrade done. thank you for your answer. I still looking for a solution. :) –  LotfiK Dec 21 '10 at 13:00
    
Just to complete my comment: i need only to authorize my Office IP address to see our websites, else All other persons should got the maintenance website. Thank you. –  LotfiK Dec 21 '10 at 13:06
    
Ok - I note that you want to use this to put a maintenance page up - but for all 200 sites at the same time? If so, then fine, but if not, then you will need to make some change to each vhost that you will be testing. –  dunxd Dec 21 '10 at 13:18
    
:) Right. We put a a maintenance page up for the 200 websites. And to test, we activated some sites with no much traffic. Now all our websites are online, we still correct some bugs. Thanks for all –  LotfiK Dec 23 '10 at 16:10

Where is your server located? If it is the same location (network wise that is) as your testers so has a local IP address as well as a public IP address, then you could have the server listen on a local IP address in the same range as your testers, and use local DNS to resolve the live site to this IP address.

You will still need to edit your vhosts for this, but frankly I don't see any way of avoiding that given what information you have given.

share|improve this answer
    
Thanks for your answers. Our webserver is hosted out of the office (ovh.com france). The testers are the developers of our office and me. We can take some sites and enable them for test in which we implement IP restrictions in each website: the idea is on these websites, if the visitor's IP address is different from our office IP address we redirect this visitor to our maintenance website else we display the website. –  LotfiK Dec 21 '10 at 13:38
    
I've put the additional information you gave into the question. Hopefully this will help get you a better answer from someone with more relevant experience. –  dunxd Dec 21 '10 at 13:52
    
I'll give you a feedback when done. Thanks –  LotfiK Dec 21 '10 at 14:58
    
Yesterday, we finished working at 10:00 PM. We put all our sites in maintenance mode at 15H:00 and finished at 22H:00. We had to activate one virtualhost to see the result and be able to debug. So we can say that all our website became on again at 22H:00. Thank you for your ideas. –  LotfiK Dec 23 '10 at 10:41
    
Glad things worked out for you. How did you do it in the end? –  dunxd Dec 23 '10 at 10:50

Set up a separate machine(virtual?) to serve the current content and point all new traffic at that. Then upgrade your other server with the new content. When you are satisfied with the new content, point all traffic back at the main server. This has the added benefit of not requiring a maintenance page.

share|improve this answer
    
Sorry i didn't see your post. We don't have enough servers to do this. the reason to display the maintenance website is to prepare all the data we need on our production servers. Thank you. –  LotfiK Dec 23 '10 at 10:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.