how to Redirect two URL's on same port to two diff IP's internally

假如想象 提交于 2019-12-06 07:28:16

One possibility is to have machine A act as a proxy for machine B. Meaning all requests for both domains go to machine A on port 80, but then you set up name based virtual hosts in apache. The virtual host for url2.xyz.com then forwards on the request to machine B.

Something like this:

Virtual hosts on machine A:

<VirtualHost *:80>
ServerName url1.xyz.com
DocumentRoot /var/www/url1
</VirtualHost>

<VirtualHost *:80>
ServerName url2.xyz.com
ProxyPass / http://url2.machineB/
ProxyPassReverse / http://url2.machineB/
</VirtualHost>

And then on machine A you define url2.machineB to point to the IP address of machine B. You do this by adding a line to the file /etc/hosts. Then on machine B you create an apache virtual host to listen for that domain, like so:

<ViirtualHost *:80>
ServerName url2.machineB
DocumentRoot /var/www/url2
</VirtualHost>

This might not be exactly the solution, but should give you one option to take. See http://httpd.apache.org/docs/2.2/mod/mod_proxy.html for more on proxying.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!