title: Docker compose, NGINX not serving static files
body: <p>I am trying to serve a simple <code>Flask</code> app over with <code>NGINX</code> using <code>Docker Compose</code>. But NGINX will not serve my static files.</p>
  
  <p>I am using an <code>Ubuntu 18.04</code> box. Here is my file structure:</p>
  
  <pre><code>    .
      ├── docker-compose.yml
      ├── nginx
      │   └── sites-enabled
      │       └── nginx.conf
      ├── README.md
      ├── uwsgi.ini
      └── web
          ├── app
          │   ├── __init__.py
          │   ├── static
          │   │   ├── pics
          │   │   │   ├── headshot1.jpg
          │   │   │   └── headshot2.jpg
          │   │   ├── scripts.js
          │   │   └── styles.css
          │   └── templates
          │       ├── index.html
          │       └── layout.html
          └── run.py
  </code></pre>
  
  <p>Here is my <code>nginx.conf</code>:</p>
  
  
  
  <pre><code>    http {
        server {
          listen 80;
          server_name example.com www.example.com;
  
          location /static {
            alias /usr/src/app/app/static;
          }
  
          location / {
            include uwsgi_params;
            uwsgi_pass web:5000;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          }
        }
      }
  </code></pre>
  
  <p>And my <code>docker-compose.yml</code>:</p>
  
  <pre><code>version: "2"
  
  services:
    web:
      restart: always
      build: ./web
      expose:
        - "5000"
      volumes:
        - ./web:/usr/src/app
      command: &gt;
        bash -c "uwsgi --socket :5000 \
                       --chdir /usr/src/app \
                       --wsgi-file run.py \
                       --callable app \
                       --master \
                       --processes 4 \
                       --threads 2"
  
    nginx:
      restart: always
      image: nginx:1.15
      ports:
        - "80:80"
      volumes:
        - /www/static
        - ./nginx/sites-enabled/nginx.conf:/etc/nginx/nginx.conf
      volumes_from:
        - web
      links:
        - web:web
  </code></pre>
  
  <p>When I run the containers, I can access my site from the internet, but none of the static files (CSS, images) are served. When I go into the NGINX container, I can find the static files:</p>
  
  <pre><code>$ docker exec -it my_container_1_39dbd8b7e8dc ls -l /usr/src/app/app/static/pics
  drwxr-xr-x 2 root root 4096 Feb  8 18:39 pics
  -rw-r--r-- 1 root root    0 Feb  8 18:39 scripts.js
  -rw-r--r-- 1 root root 3793 Feb  8 18:39 styles.css
  </code></pre>
  
  <p>I am not sure what I am doing wrong here. Maybe it's a file permission issue?</p>
  
  <p><strong>EDIT:</strong> adding references to <code>static/</code> directory:</p>
  
  <p><strong><code>HTML</code>:</strong></p>
  
  <p><code>&lt;link rel="stylesheet" href="/static/styles.css"/&gt;</code></p>
  
  <p><strong><code>CSS</code>:</strong></p>
  
  <pre><code>#right {
    float: right;
    background:
      linear-gradient(to bottom, rgba(0,55,164, 0.75), rgba(0, 55, 164, 0.9)),
      url(pics/headshot1.jpg) no-repeat center center;
  }
  </code></pre>