带有Apache和Nginx的Kestrel服务器反向代理

时间:2018-10-07 08:03:19

标签: apache nginx asp.net-core .net-core reverse-proxy

我已遵循guidelines在AWS AMI ec2上托管.NET core 2.1。我已经配置了反向代理,如下所示:

<VirtualHost *:*>
    RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
</VirtualHost>

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:5000/
    ProxyPassReverse / http://127.0.0.1:5000/
    ErrorLog hellomvc-error.log
    CustomLog hellomvc-access.log common
</VirtualHost>

当我尝试访问我的网站/网络api时,它会将我重定向到https://ip:5001,并显示错误“无法访问网站”

具有以下配置的nginx也是同样的问题

server {
    listen        80;
    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;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

0 个答案:

没有答案