Nginx基本使用

1.检测配置是否正确

nginx -t

2.重载配置,使其立即生效

nginx -s reload

3.代理Tomcat服务
修改Nginx.cnf文件

    location / {
        proxy_pass http://backend;   #来自jsp请求交给tomcat处理
        proxy_redirect off;
        proxy_set_header Host $host;    #后端的Web服务器可以通过X-Forwarded-For>获取用户真实IP
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
updtream backend{
    server 192.168.0.100 weight=1;
    server 192.168.0.101 weight=5;
}
Last modification:August 12th, 2019 at 09:29 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment