.Net Core + NGINX跳转登录时端口丢失


使用.Net Core + NGINX部署到服务器的时候,如果端口不是使用默认的80端口,在跳转到登录页面时,URL中的端口丢失。

NGINX的配置如下:

server {
    listen 8888;
    location / {
        proxy_pass http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection keep-alive;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

 

其实这并不是ASP.Net Core的问题,而是NGINX在返回跳转(302/301)时,没有把端口加入到“Location"中,所以只需要修改proxy_set_header,带上端口就可以了。

proxy_set_header Host $host:$server_port;

 

最后重启NGINX生效设置:

systemctl restart nginx

 

原文地址:https://www.zkea.net/codesnippet/detail/post-103.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM