NGINX与Tomcat的配置 [英] NGINX with Tomcat configuration

查看:214
本文介绍了NGINX与Tomcat的配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Nginx,我需要你的帮助,

I am new to Nginx and I need your help,

据很多论坛,我明白,我们所有的静态页面都存储在Nginx的。当有请求时我必须通过该请求到Tomcat的数据和生成的响应tomcat的响应之后。

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.

目前,我刚做了我的请求直接传递到Tomcat和响应要求。但我认为这不是高性能的解决方案。

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?

推荐答案

您可以用proxy_pass映射Tomcat服务器端口,例如:如果你的tomcat的端口是8080,你的conf / nginx.conf应配置是这样的:

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;
        }
    }
}

重启它sbin目录/ nginx的-s重装,那么当你可以访问 http://127.0.0.1 ,请求转发给tomcat的。

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

这篇关于NGINX与Tomcat的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆