Jwilder/nginx禁止给予403权限



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

我尝试按照此处的文档创建默认位置

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禁止。

据我了解,这意味着没有找到索引.html文件,但是如果我执行到我的容器和猫 app/index.html 它确实存在!

我已经检查了我所有的容器是否在同一个网络上。

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

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

更新我检查了我的nginx代理容器的日志,发现了以下错误消息:

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

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

我错过了什么?

我的问题是基本的误解,即反向代理可以进入我的容器的文件系统,正如 jwilder 本人在这里所说的那样。

因此,在我的情况下,反向代理上的默认位置是不必要的。相反,我可以简单地让它指向我的容器,并让容器中的nginx配置确定我的应用程序的位置。

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

相关内容

最新更新