
我剛剛在 Visual Studios 上創建了一個基本應用程序,並嘗試讓它在 Nginx 代理上的 Ubuntu 伺服器上運行。一旦我啟動它,應用程式就會運行,但前端無法找到靜態文件,並在 6 個靜態文件上返回 net::ERR_ABORTED這個螢幕擷取。
我的 Nginx 代理如下:
location / {
# Proxy for dotnet app
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;
}
我有 Certbot 設定來提供 SSL。我的 Nginx 錯誤檔案中也沒有收到任何錯誤。
如何解決靜態檔案上的 net::ERR_ABORTED 問題?
答案1
問題是 Nginx 伺服器無法在 Web 根目錄中找到檔案。以下程式碼在請求後從指定目錄提供靜態檔案...
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$ {
root /path/to/static/content;
}