Nginx Load Balancer Configuration One (reverse proxy)

Source: Internet
Author: User

First, the premise

1: System Linux (CentOS)

2:nginx Proxy Server (web:192.168.1.10 proxy.abc.com)

3:nginx Background Server (web1:192.168.1.11 www.abc.com web2:192.168.1.12 backend.abc.com)

Second, configuration (192.168.1.10)

1: Configure/usr/local/nginx/config/nginx.conf

Remove server{} and introduce all server configurations via include config.d/*.conf

Add the following lines at the end of the nginx.conf:

ABC {               127.0. 0.1:8000;         # # #通过IP                # #127.0. 0.1:8001;              server www.abc.com:  8000;     # # #通过域名 # #               server backend.abc.com:8001;} Include CONF.D/*. conf  ;

2: Configuration

/usr/local/nginx/config/config.d/proxy.conf

Server {Listen the;        server_name proxy.xiaohuideng.com; #charset Koi8-R; #access_log logs/Host.access.log Main; Location/{index index.html index.htm; proxy_set_header Host $http _host;                # # #默认是以IP为负载 (Proxy_set_header Host $host;)  Proxy_buffering off;
Proxy_set_header X-real-ip $remote _addr; # #不过滤掉真实请求IP地址 Proxy_pass http:// ABC; # # #引入upstream所定义的名字} error_page - 502 503 504/50x.html; Location= /50x.html {}}

Three, restart Nginx (192.168.1.10)
/USR/LOCAL/NGINX/SBIN/NGINX-T # #测试配置是否OK
/usr/local/nginx/sbin/nginx-s Reload # # #重新加载配置


Iv. Viewing effects
Visit http://proxy.abc.com on a remote PC browser to see if it gets backend.abc.com with Www.abc.com's page switch

Nginx Load Balancer Configuration One (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.