There are 2 servers:

  • one eth0 eth1 on eth0 has an external address 1.2.3.4 eth1 internal 192.168.1.1
  • at the second eth0 192.168.1.2

Apache2 is installed on both
All sites are registered in DNS on this external ip. On the first server where the external IP turns 5 sites
On the second server 1 site in default.
How to show all the sites on the Internet? Is it possible to put nginx or are there other options?

  • One of the easiest options is to pick up on the first proxy and go to sites through a proxy. - nick_n_a
  • can be more? - Viktor

1 answer 1

Nginx supply is a good option. Get at the same time and buns in the form of faster processing of statics. In nginx, for your purposes you will need to use the directive proxy_pass, which tells you where to redirect the request. It will be something like this:

server { listen 1.2.3.4:80; server_name <имя_сайта_со_второго_сервера>; location / { proxy_pass http://192.168.1.2:80/; } } 

Documentation on the module ngx_http_proxy_module, responsible for proxying requests.

  • Yes, in principle, I did. But I substituted the server_name <ip_со_второго_сервера>; If I put the name, then you need to raise the dns on a real server with a zone that will only work on localhost or write to the hosts server. The first question is if there are 2 or 3 sites on the second server, will it work? and `Get at the same time and buns in the form of faster processing of statics.` Question two: Can you handle statics from the second server? - Viktor
  • @Viktor: Well, if the second server has more than one site, then you will need to somehow distinguish them. So either the first server will need more external IP, so that each site has its own IP address, or they will have to be given names. To process a statics on the second server - it will be possible. If on the second server to put nginx. Well, you can still nginx'om external server to cache responses from Apache on the second server, but this is not the same. - MAN69
  • Ie, if I have 1 external IP and domain site.com. then I can show in the internet all the sites that will be on subdomains (for example, a.site.com, b.site.com on one server with an external IP, and c.site.com, d.site.com on the second, but on gray ip)? - Viktor
  • @Viktor - yes. Site and 4th subdomains give one IP - the first, external server. On it, in nginx, you create 4 server blocks, with different parameters for the server_name directive. For the main site and subdomains "a" and "b" - do the processing of requests on the same server. For the remaining two subdomains, write proxy_pass to the IP of the second server and add proxy_set_header Host $host; , what would be passed the correct name of the site. - MANKK
  • Then on the second server, just pick up Apache with vhosts gray ip and site names? It is not necessary on the first server to raise the DNS server for lokalkhosta to correctly display the site from the second server, proxy_set_header Host $ host; is enough ;? - Viktor