简体   繁体   English

nginx 403 禁止错误

[英]nginx 403 Forbidden error

I'm trying to set up graphite to work with grafana in docker based on this project : https://github.com/kamon-io/docker-grafana-graphite我正在尝试根据这个项目在 docker 中设置石墨以与 grafana 一起使用: https : //github.com/kamon-io/docker-grafana-graphite

and when I run my dockerfile I get 403 Forbidden error for nginx.当我运行我的 dockerfile 时,我收到 403 Forbidden 错误。

my configurations for nginx are almost the same as the project's configurations.我对nginx的配置和项目的配置几乎一样。 I run my dockerfiles on a server and test them on my windows machine.我在服务器上运行我的 dockerfiles 并在我的 Windows 机器上测试它们。 So the configurations are not exactly the same ... for example I have :所以配置并不完全相同......例如我有:

server {
listen 80 default_server;
server_name _;
location / {
  root /src/grafana/dist;
  index index.html;
}
location /graphite/ {
    proxy_pass                 http:/myserver:8000/;
    proxy_set_header           X-Real-IP   $remote_addr;
    proxy_set_header           X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_set_header           X-Forwarded-Proto  $scheme;
    proxy_set_header           X-Forwarded-Server  $host;
    proxy_set_header           X-Forwarded-Host  $host;
    proxy_set_header           Host  $host;

    client_max_body_size       10m;
    client_body_buffer_size    128k;

    proxy_connect_timeout      90;
    proxy_send_timeout         90;
    proxy_read_timeout         90;

    proxy_buffer_size          4k;
    proxy_buffers              4 32k;
    proxy_busy_buffers_size    64k;
    proxy_temp_file_write_size 64k;

    add_header Access-Control-Allow-Origin "*";
    add_header Access-Control-Allow-Methods "GET, OPTIONS";
    add_header Access-Control-Allow-Headers "origin, authorization, accept";
}

But I still keep getting 403 forbidden.但我仍然不断收到 403 禁止。 Checking the error log for nginx says :检查 nginx 的错误日志说:

 directory index of "/src/grafana/dist/" is forbidden

Stopping and running it again it says :停止并再次运行它说:

 directory index of "/src/grafana/dist/" is forbidden

I'm very new to nginx ... was wondering if there's something in the configurations that I'm misunderstanding.我对 nginx 很陌生……想知道配置中是否有我误解的东西。

Thanks in advance.提前致谢。

那是因为您正在点击第一个位置块并且未找到索引文件。

A request to '/' will look for 'index.html' in '/src/grafana/dist'.对“/”的请求将在“/src/grafana/dist”中查找“index.html”。

Confirm that: 1. 'index.html' exists.确认: 1. 'index.html' 存在。 2. You have the right permissions. 2. 您拥有正确的权限。 nginx has read-access to the entire directory tree leading up to 'index.html'. nginx 具有对整个目录树的读取访问权限,直到“index.html”。 That is, it must be able to read directories 'src', 'src/grafana' and 'src/grafana/dist' as well as 'index.html' itself.也就是说,它必须能够读取目录“src”、“src/grafana”和“src/grafana/dist”以及“index.html”本身。 A hacky quick-fix to achieve this would be to do 'sudo chmod -R 755 /src', but I don't recommend it.实现这一点的一个hacky快速修复是执行'sudo chmod -R 755 /src',但我不推荐它。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM