NGINX with Tomcat configuration

。_饼干妹妹 提交于 2019-12-03 14:19:39

问题


I am new to Nginx and I need your help,

According to many forums I understood that all our static pages are stored in Nginx. When there is request comes I have to pass that request to tomcat for data and after response from tomcat response generated.

Currently, I have just done that I request directly passed to tomcat and respond to request. but I think that is not solution for performance.

So anyone can Help me?


回答1:


You can using proxy_pass mapping to your tomcat server port, for example : if your tomcat port is 8080, your conf/nginx.conf should be configured like this:

...
http {
    ...

    server {
        location / {
            proxy_pass http://127.0.0.1:8080;
            proxy_set_header X-Real-IP $remote_addr;
        }
    }
}

restart it sbin/nginx -s reload, then when you can access http://127.0.0.1, the request forward to tomcat.

Configuration file is placed commonly under:

/etc/nginx/nginx.conf


来源:https://stackoverflow.com/questions/11410527/nginx-with-tomcat-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!