我想反向代理我的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)。 –