403 Forbidden error when using nginx inside docker

3.7k views Asked by At

I am trying to build a nginx webserver to share files among team members.

In 'ubuntu 16.04', I am running following command:

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.

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.

But if I try 'http://1.1.1.1/8081/json.txt', I am able to view the 'json.txt' contents on browser.

I want to browse all the directories and files inside.

Any idea on how to fix this issue please?

1

There are 1 answers

0
LeonG On BEST ANSWER

Please give us more context in terms of your nginx configuration. Are you using the default nginx.conf or do you have done modifications?

The solution should be to add all relevant files to the nginx index

Details also here, you will need to modify your nginx.conf: autoindex needs to be turned on for the location /