我想反向代理我的NodeJS通过NGINX后端,但我不断收到403禁止错误,nginx的记录为NGINX反向代理和静态文件
[error] 10#10: *1 directory index of "/usr/share/nginx/html/" is forbidden,
client: 172.20.0.1, server: localhost, request: "GET/HTTP/1.1",
host: "localhost:8888
我的服务器模块配置:
server {
charset utf8;
listen 80 default_server;
location/{
proxy_pass http://localhost:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_valid 200 1s;
}
location /assets/ {
expires 30d;
add_header Cache-Control "public";
root /usr/share/nginx/html/;
try_files $uri =404;
}
}
经过一番研究,似乎它可能与NGINX identifying /
as a query for a directory listing有关,并且很可能会要求我添加index index.html
来解决问题(它没有)。我的配置也匹配that presented by the official NGINX configurations反向代理。
有没有人有一个想法如何解决这个问题?
任何帮助将不胜感激! 干杯:)
我不明白'localhost:8888'部分的错误信息。您还应该使用'nginx -T'测试您的配置。 –
localhost:8888是我从中调用请求的主机。我不相信它与它有任何关系,但我的设置在docker中运行(请参阅此[docker-compose文件](https://github.com/futureboyHQ/website/blob/feature/6/docker/docker) -compose.yml))。尽管它没有提供更多信息,但您可以在这里找到'nginx -T'打印输出(https://pastebin.com/HHAk1Kba)。 –