从nginxredirect中删除端口

我有一个问题,网站上的一些redirect包含代理通过端口,使其无用。 我的configuration如下:

物理服务器1:

server { server_name example.com www.example.com; location / { proxy_pass http://1.1.1.1:50493; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host "example.com"; } } 

物理服务器2:

 server { listen 50493; server_name example.com www.example.com; set_real_ip_from 1.1.1.1; root /var/www/example.com; index index.php index.htm index.html; location / { if ($http_host !~ "^example.com"){ set $rule_0 1$rule_0; } if ($rule_0 = "1"){ rewrite ^/(.*) http://example.com/$1 permanent; } rewrite /[^/]+/([0-9]+)-[^/]+.html http://example.com/showthread.php?t=$1 permanent; } location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/example.com$fastcgi_script_name; include fastcgi_params; fastcgi_read_timeout 600s; fastcgi_buffer_size 512k; fastcgi_buffers 16 512k; } } 

一般来说,浏览工作正常。 该网站是可以浏览的。 然而,一些redirect的链接(例如login操作之后),redirect到包含端口50493的链接。 所以我们拿http://example.com:50493/index.php为例。 这是行不通的。 我的问题是,我如何删除端口?

从我可以告诉,论坛软件从PHP会话端口variables端口。 我试过设置port_in_redirect但无济于事。 如果有帮助,这里突出显示的问题: http : //kb.parallels.com/en/114425是类似的。

谢谢。

它告诉你如何解决你提供的链接中的问题。 更改:

 <?php echo $VAR->domain->asciiName ?>:<?php echo $OPT['ssl'] ? $VAR->server->webserver->httpsPort : $VAR->server->webserver->httpPort ?>" 

 <?php echo $VAR->domain->asciiName ?>" 

你必须在你的应用程序而不是Nginx中解决这个问题。

您的应用程序正在生成指向端口50493的链接。 除非你打算设置一个遍历所有HTML的内容过滤器,并用example.com:50493/path/of/url替换example.com:50493/path/of/url ,那么你必须在应用程序中修复它。

在你的nginx.conf中

 http { port_in_redirect off; } 

尝试在飞行中的替代

HttpSubmodulee

 sub_filter 'example.com:50493/' 'example.com/' ; sub_filter_once off; 

这应该做的伎俩。