【发布时间】:2021-03-12 06:27:10
【问题描述】:
我目前正在学习 ASP.NET,并在我的开发盒上发布了我的第一个应用程序。 现在我正试图把它放在 nginx 后面。
location / {
try_files $uri $uri/ @dotnet;
}
location @dotnet {
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;
}
但这会导致 403。在日志中它说目录列表是禁止的 /path/to/wwwroot/
目前我正在使用
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;
}
但这样一来,静态文件由 Kestrel 提供服务。
【问题讨论】:
标签: asp.net linux nginx reverse-proxy