小智 29

我刚刚遇到了同样的问题并且port_in_redirect off;实际上对我有用,只要确保你在server {}块内使用它。

server {
  listen 8080;
  server_name example.com;

  port_in_redirect off;
  autoindex on;

  location / {
    root /var/www/example.com;
    index index.html;
  }
}
Run Code Online (Sandbox Code Playgroud)

  • 或者甚至在“location”中使用“port_in_redirect”。 (2认同)

小智 5

应该可以解决问题。proxy_redirectproxy_pass指令之后添加指令

proxy_redirect http://example.com:8080/ http://example.com/;


Zer*_*ero 0

http://wiki.codemongers.com/NginxHttpCoreModule#port_in_redirect

syntax: port_in_redirect [ on|off ]
default: port_in_redirect on
context: http, server, location
Run Code Online (Sandbox Code Playgroud)

希望这就是您正在寻找的。