简体   繁体   English

在docker中使用nginx时出现403禁止错误

[英]403 Forbidden error when using nginx inside docker

I am trying to build a nginx webserver to share files among team members.我正在尝试构建一个 nginx 网络服务器来在团队成员之间共享文件。

In 'ubuntu 16.04', I am running following command:在“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

As shown below docker is able to mount the files successfully.如下图 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# 

But when I try to access webserver using browser "http://1.1.1.1/8081" I am seeing '403 forbidden' error.但是当我尝试使用浏览器“http://1.1.1.1/8081”访问网络服务器时,我看到“403 禁止”错误。

But if I try 'http://1.1.1.1/8081/json.txt', I am able to view the 'json.txt' contents on browser.但是如果我尝试“http://1.1.1.1/8081/json.txt”,我就可以在浏览器上查看“json.txt”的内容。

I want to browse all the directories and files inside.我想浏览里面的所有目录和文件。

Any idea on how to fix this issue please?关于如何解决这个问题的任何想法?

Please give us more context in terms of your nginx configuration.请根据您的 nginx 配置为我们提供更多背景信息。 Are you using the default nginx.conf or do you have done modifications?你是使用默认的 nginx.conf 还是做了修改?

The solution should be to add all relevant files to the nginx index解决办法应该是将所有相关文件添加到nginx索引中

Details also here, you will need to modify your nginx.conf: autoindex needs to be turned on for the location /详细信息也在这里,您将需要修改您的 nginx.conf: 需要为该位置打开自动索引 /

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

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