nginx error 403 – directory index is forbidden

I am trying to connect docker nginx with docker flask. Here is the structure of my project:

├── storage
│   ├── nginx
│   │   └── static
│   │       └── image.gif
└── web
    └── flask
        ├── app
        │   ├──
        │   └── templates
        │       └── index.html
        ├── conf
        │   ├── nginx-default.conf
        │   ├── nginx-flask.conf
        │   └── requirements.txt
        └── Dockerfile

Although curl and curl work fine, I get a ‘403 Forbidden’ error when I do curl More specifically, nginx gives the following error:

  • Docker-compose hanging on pulling image where Dockerfile doesn't
  • App stop working recently: File not Found in Laravel using Docker
  • Open/Edit/Save from on the host with app running in container
  • Does Docker override files?
  • Sending docker logs to AWS CloudWatch via Terraform
  • Allow communication between two docker bridge networks using docker-compose
  • 2016/03/05 17:54:37 [error] 8#8: *1 directory index of "/usr/share/nginx/html/" is forbidden, client:, server: localhost, request: "GET / HTTP/1.1", host: "localhost" - - [05/Mar/2016:17:54:37 +0000] "GET / HTTP/1.1" 403 169 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0" "-"

    I create the containers like this:

    docker create \
    -v $ROOT/web/flask/app/:/web/flask/app/ \
    --name flask_data flask:0.1
    docker run \
    -d -p \
    --volumes-from flask_data \
    --name flask_service flask:0.1
    docker create \
    -v $ROOT/storage/nginx/:/usr/share/nginx/html/ \
    --name nginx_data nginx:1.9
    docker run \
    -v $ROOT/web/flask/conf/nginx-flask.conf:/etc/nginx/conf.d/nginx-flask.conf \
    -v $ROOT/web/flask/conf/nginx-default.conf:/etc/nginx/conf.d/default \
    -d -p \
    --volumes-from nginx_data \
    --link flask_service:flask_service_alias \
    --name nginx_service nginx:1.9

    where, Dockerfile is:

    FROM ubuntu:14.04
    RUN apt-get update && apt-get install -y --no-install-recommends python-pip python-dev
    COPY . /web/flask/
    RUN pip install -r /web/flask/conf/requirements.txt
    CMD gunicorn run:app --workers=4 --bind= --log-level=debug --timeout=43200 --chdir=/web/flask/app/

    and requirements.txt is:


    nginx-default is empty, and nginx-flask is:

    server {
        listen          80;
        charset         utf-8;
        location /avatar {
            alias /usr/share/nginx/html/avatar;
        location /scan {
            alias /usr/share/nginx/html/scan;
        location /static {
            alias /usr/share/nginx/html/static;
        location / {
            proxy_pass http://flask_service_alias:50/;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    any ideas?

  • HTTP Code 504 while uploading layer “”
  • Docker Windows - Looking for Ubuntu command in bash location
  • Excuting a shell script in code fails while it works in the terminal
  • Virtualbox port forwarding with docker
  • Dockerfile RUN vs run image and use /bin/bash provides different result
  • What is a Docker tag (looking for a definition)?
  • One Solution collect form web for “nginx error 403 – directory index is forbidden”

    It looks like what might be going on is the default.conf file in the nginx image is taking over the / location. You nginx run command has:

    -v $ROOT/web/flask/conf/nginx-default.conf:/etc/nginx/conf.d/default \

    This should be overwriting the default.conf instead of just default. As it currently stands, it just adds another blank default file and leaves the default default.conf which has a location for /.

    You static route does work because there is an explicit route in the nginx-flask.conf to /static and you call the file explicitly. You get a 403 on the / location because indexes are disabled by default (controlled by the autoindex option).

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.