0

I have several machines on my lan. On of them is running 2 web sites, first_web_site and second_web_site (each one in a dedicated NameVirtualHost). Another machine is running another site third_web_site. I would like to be able to access each one, within internet, with the url:

  • first_web_site.domain.tld
  • second_web_site.domain.tld
  • third_web_site.domain.tld

knowing that 2 sites are on the same machine. Can Apache help me to do this ?

I have a machine that will have a apache server to be used for proxy purposes. I was talk to set up virtualhost on this one and use proxy server but I do not know how to do this.

Could you please give me hints ? Thanks a lot, Luc

2 Answers 2

1

Create or edit the vhosts.conf in your apache conf.d (or equivalent depending on OS).

Use the NameVirtualHost directive to handle the DNS names.

NameVirtualHost *:80 

Then define each of your virtual hosts. Something like the following:

<VirtualHost *:80> ServerName sub1.domain.com ProxyRequests Off ProxyPreserveHost On # use the IP address or DNS or the server to forward to # can include the port as well if necessary ProxyPass / http://x.x.x.1/ ProxyPassReverse / http://x.x.x.1/ </VirtualHost> <VirtualHost *:80> ServerName sub2.domain.com ProxyRequests Off ProxyPreserveHost On ProxyPass / http://x.x.x.2/ ProxyPassReverse / http://x.x.x.2/ </VirtualHost> 

For the two sites on the same box, it depends on how they're setup. If they're on different ports, define the ports, if they're paths, then you'll need to add the path on the end of the ProxyPass and ProxyPassReverse entries:

http://x.x.x.1/app1 
3
  • You could also wrap the ProxyPass and ProxyPassReverse directives in a Location directive. Commented Mar 19, 2010 at 21:54
  • Thanks tgm, I still have some pb: on my proxy machine, in ports.conf: " NameVirtualHost *:80 Listen 80 " and in my VirtualHosts: " <VirtualHost *:80> ServerName test.domain.tld ProxyRequests Off ProxyPreserveHost On ProxyPass / 192.168.1.150:81 ProxyPassReverse / 192.168.1.150:81 </VirtualHost> " and on the machine hosting the sites: <VirtualHost 192.168.1.150:81> ServerName test.domain.tld DocumentRoot /home/www/test/public </VirtualHost> <Directory "/home/www/test/public"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> Commented Mar 20, 2010 at 14:07
  • hello, that's exactly what I needed, this is working fine. Thanks a lot. Commented Mar 21, 2010 at 13:32
2

You could setup a proxy on the first box that connects and tunnels to the second one. This is so that the second box does all the heavy lifting, the first one will only need the resources to display the page.

1
  • 2
    Sounds like he wants a combination of proxypass and virtualhosts. Commented Mar 19, 2010 at 17:44

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.