简体   繁体   English

使用 nginx 反向代理表示问题,不发送 static 文件

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

Nginx when I ask for my static file always returns 404, but with I understand what the reason is, if I'm wrong something that surely is so you can explain to me why it was wrong: here are the configuration files: Nginx 当我询问我的 static 文件时总是返回 404,但我明白原因是什么,如果我错了,那肯定是这样,你可以向我解释为什么错了:这里是配置文件:

default.conf默认.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;
    }

}

Following two articles helped me:以下两篇文章帮助了我:

.Net Core 3.0 Nginx not serving static files .Net Core 3.0 Nginx 不提供 static 文件

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

I added following two blocks under my server block:我在我的服务器块下添加了以下两个块:

  location /assets/ {
     }

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 配置 Nginx 为 Angular 的 Static 文件提供服务,并为 express 提供反向代理 - Configure Nginx to serve Static files of Angular and also reverse proxy for express Nginx 不会提供 static 文件(反向代理 + Express API)? - Nginx won't serve static files (Reverse Proxy + Express API)? 在Express中处理重定向以支持Nginx反向代理 - Handling redirects in Express to support nginx reverse proxy 如何使用多个 Express 应用程序 + NGINX 作为反向代理服务器提供 static 文件(CSS,...) - How to serve static files (CSS, …) with multiples Express app + NGINX as reverse proxy server Express会话在NGINX反向代理上不持久 - Express-session is not persistent on NGINX reverse proxy 使用SSL的NodeJS Express无法使用Nginx反向代理 - NodeJS Express with SSL not working with Nginx reverse proxy Ajax POST 到 php 文件从 nodejs express 服务器与 nginx 反向代理在树莓派 - Ajax POST to php file from nodejs express server with nginx reverse proxy on raspberry pi nginx作为Express Server 504网关超时的反向代理 - nginx as reverse proxy for express server 504 Gateway Time-out 用于 express.js 服务器的 docker 中的 Nginx 反向代理 - Nginx reverse proxy in docker for express.js server 具有Express和Nginx反向代理的Vue路由器历史记录模式 - Vue Router history mode with Express and nginx reverse proxy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM