nginx或apache添加端口,如果url中没有斜杠


nginx or apache add port if in url no slash

我有nginx+apache+php配置。如果我在浏览器中写"http://example.com服务器将我重定向到"http://example.com:8080"(8080是我的Apache端口),但如果我添加斜杠(如example.com/),效果会很好。nginx-config:

server {
    location / {
            proxy_pass   http://127.0.0.1:8080;
            proxy_read_timeout 600;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header  X-Forwarded-For   $remote_addr;
            proxy_buffering off;
    }

解决方案:添加nginx配置行:

port_in_redirect off;