The company has three machines in the computer room, because the IP is not enough, must be separated, so to establish a single IP multi-domain reverse proxy,
is when request www.abc.com jump to this machine, request www.bbc.com jump to 192.168.0.35 machine up,
The premise 192.168.0.35 installed nginx and PHP environment.
#vi/usr/local/nginx/conf/nginx.conf
#修改其中的配置
Upstream www # www can be customized, the following name can be used to
{
Server xxx.xxx.xxx.xxx:80 max_fails=3 fail_timeout=30s; #可使用内网IP, the port can use 80, and so on, the server runs a port that needs listening.
}
Upstream BBS
{
Server xxx.xxx.xxx.xxx:8080 max_fails=3 fail_timeout=30s;
}
server {
Listen 80;
server_name www.abc.com;
Location/{
Index index.html index.php index.jsp index.htm;
Proxy_pass http://www; #和上面定义的名称对应, only for Httpurl.
Proxy_redirect off;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
#proxy_connect_timeout 90;
#proxy_send_timeout 90;
#proxy_read_timeout 90;
#proxy_buffers 4K;
}
}
server {
Listen 80;
server_name bbs.abc.com;
Location/{
Index index.html index.php index.jsp index.htm;
Proxy_pass Http://bbs;
Proxy_redirect off;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
#proxy_connect_timeout 90;
#proxy_send_timeout 90;
#proxy_read_timeout 90;
#proxy_buffers 4K;
}
}
```````````````````````````````````````````````````````````````````````````````
Of course, this is simply through the domain name of the host forwarding request, if the load balance, Nginx is mostly to receive the host to poll, so in the host group inside add hosts can be.
Upstream BBS
{
Server xxx.xxx.xxx.xxx:8080 max_fails=3 fail_timeout=30s;
Server 192.168.0.23:80 max_fails=3 fail_timeout=30s;
}
Then is the nginx detection configuration, restart the server.
#/usr/local/nginx/sbin/nginx-t
#service nginx Restart.
Then request a different domain name, multiple machines will be refreshed several times, found that the request was distributed to different machines.
Then you can laugh and make a good log, waiting for the server to monitor the script.
Nginx domain forwarding load balancer Reverse proxy