Z
Z
ZoomZoom2014-03-08 05:50:52
Apache HTTP Server
ZoomZoom, 2014-03-08 05:50:52

2 servers on port 80 - how to implement?



There is 1 external IP address, and a local network in which 2 web servers (Apache) in the local network have a Dir620 router, port 80 is open, the first server has IP 192.168.0.5, the second server has IP 192.168.0.6 site1.domain.ru opened exactly the virtual host that is registered on another server. Is it possible to make 2 web servers work at the same time and, when requested, go to the desired site?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
S
Salavat Sharapov, 2014-03-13
@desperadik

DO NOT need any second second ip. Just on one of the servers, raise mod_proxy for Apache to port 80 (for example, for debian: sudo apt-get install libapache2-mod-proxy-html libapache2-mod-gnutls), and transfer the virtual host from the site of this server to some other port . (e.g. 12345) Then configure proxy configs (I advise you to create a separate config for each virtual host):
Examples for debian:
a2enmod proxy
touch proxy.site.local (e.g. for 192.168.0.5)
vi proxy.site.local

<VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot "/var/www/test"

        ServerName      proxy.site.local
        ServerAlias     site1.domain.ru www.site1.domain.ru

        ProxyRequests Off
        ProxyPreserveHost On
        ProxyVia full

        <Proxy *>
        Order deny,allow
        Allow from all
        </Proxy>

        ProxyPass / http://127.0.0.1:12345/
        ProxyPassReverse / http://127.0.0.1:12345/
</VirtualHost>

We save.
After we connect another site to the proxy (192.168.0.6)
touch proxy.site2.local
vi proxy.site2.local ServerAdmin
[email protected]
DocumentRoot "/var/www/test2"
ServerName proxy.site2.local
ServerAlias ​​site2.domain.ru www .site2.domain.ru
ProxyRequests Off
ProxyPreserveHost On
ProxyVia full
Order deny,allow
Allow from all
ProxyPass / http://192.168.0.6:80/
ProxyPassReverse / http://192.168.0.6:80/
And do not forget to specify in ports. conf local site port.
Now, if you are accessed from outside, for example, site1.domain.ru will go to 192.168.0.5 (Apache will transfer to localhost), and if site2.domain.ru - then to 192.168.0.6. (Apache will check by alias and redirect to 0.6:80)
And yet, be sure to redirect port 80 on the router to the IP on which Apache is installed with a proxy. If you have questions: sk desperadik2

T
Tortway, 2015-09-13
@Tortway

Hi, it's been over a year now. Please answer, were you able to implement it? If so, how? I have the same task.

T
t_q_l, 2014-03-08
@t_q_l

I suppose that this can be implemented if you flash Dir620 using OpenWRT and install nginx there .

V
Vlad Zhivotnev, 2014-03-08
@inkvizitor68sl

Lighttpd may be running on dir620. Then in its config you can do this .
If there is no light there, then only installing nginx on one of the servers will help, which will proxy requests for the required http_host to another server. All traffic from the router, accordingly, will need to be forwarded to the server with nginx.

Z
ZoomZoom, 2014-03-08
@ZoomZoom

If I take 2 external address? how can it be implemented?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question