nginx 后接jett/tomcat

不需要改jetty/tomcat的配置,只需要修改nginx.conf

引用

http{

      

        server{

                listen 80; 

                server_name www.xxx.com www2.xxx.com;

                location / {

                    proxy_pass              http://localhost:8080;

                    proxy_set_header        X-Real-IP $remote_addr;

                    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

                    proxy_set_header        Host $http_host;

                }

        }

}

另外,经过以上设置后,在servlet里拿request.getServerName()和request.getServerPort()会跟浏览器里输入的一致。

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.