簡體   English   中英

使用 nginx 反向代理表示問題,不發送 static 文件

[英]Problem express with nginx reverse proxy, not send static file

Nginx 當我詢問我的 static 文件時總是返回 404,但我明白原因是什么,如果我錯了,那肯定是這樣,你可以向我解釋為什么錯了:這里是配置文件:

默認.conf

upstream apps {
  server webapi:9000 fail_timeout=10s max_fails=5;
}

server {
    listen 80 default_server;
    large_client_header_buffers 4 16k;

    location @apphost {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;
      proxy_pass http://apps;
      proxy_redirect off;
    }

}

以下兩篇文章幫助了我:

.Net Core 3.0 Nginx 不提供 static 文件

https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/

我在我的服務器塊下添加了以下兩個塊:

  location /assets/ {
     }

  location ~ \.(css|js|lib|png) {
        root /var/apps/dev/myapp/wwwroot;
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM