我试图将第二个品牌的网络应用折叠为第一品牌,并使用301重定向来重定向任何滞留的流量。该服务器在流浪箱转发端口8001。我想有运行:当301重定向时,nginx保留端口号
而不是https://local-dev-url:8001/foo/(anything)https://local-dev-url:8001/(anything)
而不是https://local-dev-url:8001/adminfoo/(anything)https://local-dev-url:8001/admin/(anything)。
这是我有:
location ~ /foo/?(.*)$ {
return 301 $1/;
}
location ~ /adminfoo/?(.*)$ {
return 301 admin/$1/;
}
location/{
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Port 443;
proxy_set_header Authorization $http_authorization;
proxy_set_header X-Scheme $scheme;
proxy_pass http://127.0.0.1:5000;
proxy_redirect http:// $scheme://;
}
location /admin/ {
alias /hostonly/path/to/admin/stuff/;
}
然而,而不是重定向https://local-dev-url:8001/foo/到https://local-dev-url:8001/它301ing到https://local-dev-url//代替。 (没有端口号,额外的斜线)。我看到了对重定向URL进行硬编码的答案,但由于我与其他许多开发人员合作,并且我们都有独特的本地开发URL,唯一一致的部分是: 8001端口号。
有没有办法将301配置为按照需要工作?
此服务器侦听的端口是什么?你是否将8001转到80? –
@RichardSmith港口443,而不是80。 –