.Net 配置 swagger 使用nginx反向代理后请求带端口号导致无法正常访问---解决方法

1 webconfig中 appsetting 中增加配置

<appSettings>
    <add key="aspnet:UseHostHeaderForRequestUrl" value="true"/>
</appSettings>

2 nginx 配置

upstream www.baidu.com {
    server 127.0.0.1:10178 weight=1 fail_timeout=0;
}

server {
    listen 80;
    listen 443 ssl;
    server_name www.baidu.com;

    ssl_certificate ./cert/www.baidu.com/1_www.baidu.com_bundle.crt;
    ssl_certificate_key ./cert/www.baidu.com/2_www.baidu.com.key;

    location / {
        proxy_pass http://www.baidu.com;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
    }

}
                            
                            

 

posted @ 2019-06-04 11:18  eedc  阅读(2812)  评论(0编辑  收藏  举报