当前位置: 移动技术网 > IT编程>开发语言>.net > .Net Core + NGINX跳转登录时端口丢失

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

2018年05月17日  | 移动技术网IT编程  | 我要评论

香丝嘉人,怎样去除面部皱纹,大巴查询

使用.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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网