.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

posted @ 2018-05-16 16:35  ZKEA  阅读(1012)  评论(4编辑  收藏  举报