jwilder / nginx禁止403授权

问题描述 投票:0回答:1

我正在尝试使用带有nginx反向代理的静态index.html文件为多个容器提供服务

我尝试按照文档here创建默认位置

location / {
  root   /app;
  index  index.html;
  try_files $uri $uri/ /index.html;
}

如果我使用以下方法检查容器中的default.conf,则>]

$ docker-compose exec nginx-proxy cat /etc/nginx/conf.d/default.conf

我得到这个结果:

server {
        server_name _; # This is just an invalid value which will never trigger on a real hostname.
        listen 80;
        access_log /var/log/nginx/access.log vhost;
        return 503;
}
# xx.example.services
upstream xx.example.services {
                                ## Can be connected with "nginx-proxy" network
                        # examplecontainer1
                        server 172.18.0.4:80;
}
server {
        server_name xx.example.services;
        listen 80 ;
        access_log /var/log/nginx/access.log vhost;
        location / {
                proxy_pass http://xx.example.services;
                include /etc/nginx/vhost.d/default_location;
        }
}
# yy.example.services
upstream yy.example.services {
                                ## Can be connected with "nginx-proxy" network
                        # examplecontainer2
                        server 172.18.0.2:80;
}
server {
        server_name yy.example.services;
        listen 80 ;
        access_log /var/log/nginx/access.log vhost;
        location / {
                proxy_pass http://yy.example.services;
                include /etc/nginx/vhost.d/default_location;
        }
}

如果我检查/etc/nginx/vhost.d/default_location的内容,那正是我一开始输入的内容,所以没关系

但是,当我进入xx.example.services时,我却被禁止使用403。

据我了解,这意味着未找到index.html文件,但如果我执行到我的容器中,并且cat app / index.html它确实存在!

我已经检查过我所有的容器都在同一网络上。

我正在使用此命令运行容器

docker run -d --name examplecontainer1 --expose 80 --net nginx-proxy -e VIRTUAL_HOST=xx.example.services my-container-registry

更新

我检查了我的nginx-proxy容器的日志,发现此错误消息:

[错误] 29#29:* 1禁止“ / app /”的目录索引。]]

尝试按照this SO post删除$ uri /,但这给我留下了重定向周期。现在,我正在尝试查看是否可以设置正确的权限,但是我正在挣扎

我想念什么?

我正在尝试使用带有nginx反向代理的静态index.html文件为多个容器提供服务,我已经尝试按照此处的文档创建默认位置/ {root / app; ...

docker nginx reverse-proxy jwilder-nginx-proxy
1个回答
0
投票

很简单,您的容器中缺少/app/index.html

© www.soinside.com 2019 - 2024. All rights reserved.