Nginx代理应用端口丢失问题

Nginx代理应用端口丢失问题

 

       最近使用Nginx代理weblogic的过程中发现访问了weblogicconsole后,在应用跳转至登录界面时对应的端口号自动丢失了。比如我访问的是http://localhost:8888/console,在跳转至登录界面时地址栏的地址自动变为了http://localhost/console/login/LoginForm.jsp,很明显的是端口号丢失了。我的配置是这样的:

    server {

        listen       8888;

        server_name  localhost:8888;

 

        #charset koi8-r;      

              proxy_connect_timeout 300s;

        proxy_set_header Host $host;

        proxy_set_header Referer $http_referer;

        proxy_set_header Cookie $http_cookie;

        proxy_set_header X-Real-IP $remote_addr;

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

 

              location /emc {

                     proxy_pass http://localhost:7002;

              }

 

              location / {

 

                     proxy_pass http://127.0.0.1:7001;

 

              }

 

        location = /50x.html {

            root   html;

        }

 

    }

 

       注意上面的proxy_set_header Host $host这行,其中的host是不带端口号的,将其改为proxy_set_header Host $host:8888,问题得以解决。

 

猜你喜欢

转载自elim.iteye.com/blog/2286952