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'm using Apache, and I'm trying to set up a subdomain for a virtual host, which then points to a server on a different IP address.

So the virtual host is www.example.com, I'd like to set up images.example.com, and point it to 127.0.0.1.

I've consulted some of the answered questions on SO and other sites, but I'm a bit overwhelmed and I don't want to risk wrecking a production site.

share|improve this question
    
you do this with DNS, not at the webserver level –  sam Dec 6 '11 at 12:29
    
also, spend some time creating a test environment. It is time extremely well spent. –  alex Dec 6 '11 at 12:48
    
You are absolutely right. I don't know where my head was at. –  Squrler Dec 6 '11 at 12:50

2 Answers 2

up vote 0 down vote accepted

If you really do want to have images.example.com resolve to 127.0.0.1 then the only sensible place to do this is in the hosts file on the server. This is either /etc/host (unix like systems) or %SystemRoot%\system32\drivers\etc\hosts for windows systems e.g.

127.0.0.1    localhost images.example.com

Be aware though that 127.0.0.1 is the loopback address and is only accessible from the host on which it is defined.

share|improve this answer
    
I'm sorry, you are absolutely right. As Sam pointed out in a remark to my question, what I was trying to achieve should of course be done on the DNS level. I wasn't thinking. Thanks for answering. –  Squrler Dec 6 '11 at 12:51

The best way to do this is using DNS (an A record), however if you really want to do it with apache you could define the virtual host then use mod_proxy to pass the request to the other server. Have a look at http://httpd.apache.org/docs/current/mod/mod_proxy.html for some example

share|improve this answer

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.