.Net 配置 swagger 使用nginx反向代理後請求帶端口號致使沒法正常訪問---解決方法

1 webconfig中 appsetting 中增長配置nginx

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

2 nginx 配置web

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;
    }

}
                            
                            
相關文章
相關標籤/搜索