title: nginx : how to specify a /static to point to a docker volume?
body: <p>I have two containers : one front and one back. Both have /static folder to be used. So i ended up pointing these static folders to a common volume staticfiles.</p>
  <p>This is my docker-compose.yml :</p>
  <pre><code>version: '3.7'
  
  services:
    
    nginx_cont:
      build:
        context: .
        dockerfile: ./compose/production/nginx/Dockerfile
      restart: always
      volumes:
        - staticfiles:/usr/share/nginx/html/build/static
      ports:
        - 80:80
      depends_on:
        - web_cont
      networks:
        spa_network:
  
    web_cont:
      build:
        context: .
        dockerfile: ./compose/production/django/Dockerfile
      restart: always
      command: /start
      volumes:
        - staticfiles:/app/static
        - mediafiles:/app/media
        - sqlite_db:/app/db  
      ports:
        - 8000:8000
      env_file:
        - ./env/prod-sample
      networks:
        spa_network:
          ipv4_address: 172.20.128.2
  
  networks:
    spa_network:
      ipam:
        config:
          - subnet: 172.20.0.0/16
  
  volumes:
    sqlite_db:
    staticfiles:
    mediafiles:
  </code></pre>
  <p>My problem is in my nginx: i want to point the /static location to point to this staticfiles volume. How can i do?
  At the moment my /static folder is only pointing to one of my container static file and my web app doesnt work. This is my nginx.conf</p>
  <pre><code>server {
      listen 80;
      server_name localhost; 
      location / {
        root   /usr/share/nginx/html/build;
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
        add_header X-Frame-Options &quot;SAMEORIGIN&quot;;
      }
  
      location /wagtail {
          proxy_pass http://172.20.128.2:8000;
          proxy_set_header Host $host;
          proxy_set_header X-Forwarded-Host $host;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Script-Name /wagtail;
          client_max_body_size 20M;
  
          }
  
  
      location /static/ {
          alias /app/static/;
      }
      location /media/ {
          alias /app/media/;
      }
  }
  </code></pre>