嗨,我在 CentOS 7 上运行 dotnet core,使用 nginx 反向代理。以下是我的配置。
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name freebitcoins.zone www.freebitcoins.zone;
root /usr/share/nginx/html;
ssl_certificate "/home/Ssl/freebitcoins.zone.crt";
ssl_certificate_key "/home/Ssl/freebitcoins.zone.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
autoindex on;
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 $http_host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /websocket/ {
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 $http_host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server {
listen 80;
listen [::]:80;
server_name freebitcoins.zone www.freebitcoins.zone;
return 301 https://$server_name$request_uri;
}
我面临的问题是,它没有加载 css 或 js 文件(全部静态)。
我在 Asp.net Core Logging 中确实收到以下错误。
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.7387ms 404
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://freebitcoins.zone/web_assets/images/logo.png
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.3727ms 404
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://freebitcoins.zone/favicon.ico
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.5379ms 404
请帮我看看我做错了什么或出了什么问题。这个问题困扰了我三天了。
答案1
我明白了。任何被困在这里的人都知道。事情很简单。
dotnet /home/freeExWeb/freeExWeb.dll &
由于某种原因,这不会加载 css 或 js 文件。
但是如果你从它自己的目录运行 dotnet 进程。哇噢!
cd /home/freeExWeb/
dotnet freeExWeb.dll &