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:

  • Getting an error while trying to use a command under the lifecycle tag on kubernetes
  • How to connect to a docker box running elasticsearch inside a vagrant guest os?
  • Having error pushing docker container on Bluemix
  • How to pull image from custom docker registry with golang?
  • database and collections created in docker container cant be found in committed docker image
  • Dockerfile dosen't work on Google managed Virtual Machine
  • 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?

  • run nginx in docker with another application
  • How to remove all Docker containers
  • Dockerized PostgreSQL: psql: FATAL: the database system is starting up
  • Test Commands are not recognised in Django
  • dokku error: cannot find entity for app
  • Is it possible to have GUI for docker container?
  • 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.