Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NGINX with Tomcat configuration

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?

like image 564
sanghavi7 Avatar asked Jul 10 '12 09:07

sanghavi7


1 Answers

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
like image 198
Jason Avatar answered Oct 22 '22 21:10

Jason