Nginx domain forwarding load balancer Reverse proxy

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.