如何为tomcat集群配置Nginx根位置代理传递

时间:2017-05-15 06:33:59

标签: java tomcat nginx

我有一个在Nginx(v1)前面的tomcat(v8)集群(2个实例)上运行的Java Web应用程序。

访问网址http://localhost/MyApp

时,我的设置功能正常

但我现在想要的是只使用http://localhost

来访问我的网站

当我尝试使用以下配置时,页面会抛出一个错误,指出Too many redirects

upstream backend  {
  server web_server_1:8080;
  server web_server_2:8080;
}

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        proxy_pass http://backend/MyApp;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

在根位置配置我的tomcat集群的正确Nginx配置是什么?

0 个答案:

没有答案