Nginx 尝试打开静态文件而不是代理它们

Nginx 尝试打开静态文件而不是代理它们

我有一个非常简单的设置,我需要将两个网站合并为一个,问题是静态资产没有加载。

我看到 nginx 正在尝试打开它们,但它们应该从代理网站重定向。我尝试了带/不带尾部斜杠,带$request_uri和不带,但仍然无法加载 css。

示例日志

2018/02/05 15:38:39 [error] 37#37: *5 open() "/usr/share/nginx/html/css/styles.gz.css" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /css/styles.gz.css HTTP/1.1", host: "localhost"

我的 nginx 配置

location /css/ {
  proxy_pass https://myotherwebsite.com/css; # css is in CSS folder so I want to proxy the whole thing
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /faq {
  proxy_pass https://myotherwebsite.com/service/faq; # HTML loads, css not
}

相关内容