安装
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
配置域名和反向代理
1)需要代理的域名在阿里云加入a 解析记录 比如 demo.example.com 解析到对应的ip
2)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)配置结束,浏览器中访问 demo.example.com 可以被Nginx转发到tomcat_demo_servers上。