【问题标题】:403 Forbidden error when using nginx inside docker在 docker 中使用 nginx 时出现 403 禁止错误
【发布时间】:2021-01-13 11:05:59
【问题描述】:

我正在尝试构建一个 nginx 网络服务器来在团队成员之间共享文件。

在 'ubuntu 16.04' 中,我正在运行以下命令:

root@automation00-new:/home/test# docker run -d  -p 8081:80 -v /var/www/apj/:/usr/share/nginx/html --name test-nginx  nginx:latest

如下图docker可以成功挂载文件了。

root@automation00-new:/home/test# docker exec ec795af0f1f2 ls /usr/share/nginx/html
Builds
Logs_for_perf_Testing
json.txt
ravi
root@automation00-new:/home/test# 

但是当我尝试使用浏览器“http://1.1.1.1/8081”访问网络服务器时,我看到了“403 禁止”错误。

但是如果我尝试“http://1.1.1.1/8081/json.txt”,我可以在浏览器上查看“json.txt”的内容。

我想浏览里面的所有目录和文件。

请问您知道如何解决这个问题吗?

【问题讨论】:

  • 你需要在你的 nginx 配置文件中添加autoindex on; 指令。

标签: docker nginx containers nginx-config


【解决方案1】:

请就您的 nginx 配置提供更多背景信息。 您是使用默认的 nginx.conf 还是进行了修改?

解决方案应该是to add all relevant files to the nginx index

这里也有详细信息,你需要修改你的 nginx.conf: autoindex needs to be turned on for the location /

【讨论】:

    猜你喜欢
    • 2015-11-13
    • 2013-07-19
    • 2018-08-21
    • 2021-08-24
    • 2015-02-02
    • 1970-01-01
    • 2020-12-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多