CENTOS installs nginx and configures reverse proxy
Installation
Yum install zlib zlib-devel openssl openssl-devel pcre pcre-devel gcc gcc-c++ autoconf automake
. / configure-prefix=/usr/local/nginx-with-http_stub_status_module-with-http_ssl_module-with-http_realip_module
Make & & make install
Configure domain name and reverse proxy
1) add a resolution record to Aliyun for domain names that need to be proxied, such as demo.example.com resolution to the corresponding ip.
2) add corresponding resolution configuration to nginx.conf
Upstream tomcat_demo_servers {
Server 192.168.1.101:8080
Server 192.168.1.101:9080
}
Server {
Listen 80
Server_name demo.example.com
Location /
{
Proxy_pass http://tomcat_demo_servers;
Proxy_set_header Host $host
Proxy_set_header X-Real-IP $remote_addr
Proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
}
}
3) at the end of configuration, accessing demo.example.com in the browser can be forwarded to tomcat_demo_servers by nginx.