title: Static Media Failure with NGINX and Gunicorn
body: <p>Hello and thanks for taking time to read this request for help.</p>
  
  <p>I am installing a web application called <a href="https://github.com/netbox-community/netbox" rel="nofollow noreferrer">Netbox</a>, which is built on Django. A basic Gunicorn is front-ended with NGINX in a <a href="https://netbox.readthedocs.io/en/stable/installation/4-http-daemon/" rel="nofollow noreferrer">rather simplie configuration</a>. </p>
  
  <p><em>The problem I'm running into is that the web application reports that it is unable to load any of the static files</em>, and I can validate that I'm getting a 404 for these requests.</p>
  
  <p>I have validated that I can view the correct files in the <code>/static/</code> path referenced in the NGINX path <code>/opt/netbox/netbox/static</code>, and the permissions are correctly set as well.</p>
  
  <p>Since this is a Django web app, I have performed a simple test with the built-in test web server and all the static files are correctly rendered; this is almost certainly an issue between Gunicorn and my NGINX configuration. </p>
  
  <p><code>nginx.conf</code></p>
  
  <pre><code>server {
      listen 443 ssl;
  
      # CHANGE THIS TO YOUR SERVER'S NAME
      server_name netbox.example.com;
  
      ssl_certificate /etc/ssl/certs/netbox.crt;
      ssl_certificate_key /etc/ssl/private/netbox.key;
  
      client_max_body_size 25m;
  
      location /static/ {
          alias /opt/netbox/netbox/static/;
      }
  
      location / {
          proxy_pass http://127.0.0.1:8001;
          proxy_set_header X-Forwarded-Host $http_host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-Proto $scheme;
      }
  }
  
  server {
      # Redirect HTTP traffic to HTTPS
      listen 80;
      server_name _;
      return 301 https://$host$request_uri;
  }
  </code></pre>
  
  <p><code>gunicorn.py</code></p>
  
  <pre><code>bind = '127.0.0.1:8001'
  workers = 5
  threads = 3
  timeout = 120
  max_requests = 5000
  max_requests_jitter = 500
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Rfxqd.png" rel="nofollow noreferrer">error message when browsing http://localhost:8001/</a></p>
  
  <p>I have received the same results on the following setups:</p>
  
  <ul>
  <li>Ubuntu 18.04 (Azure)</li>
  <li>Ubuntu 19.10 (local VM)</li>
  <li>Ubuntu 20.04 (local VM)</li>
  <li>Centos 8.1 (Azure)</li>
  <li>same error when using the Apache alternative setup method</li>
  </ul>
  
  <p><strong>I would appreciate any ideas on where I can go to validate things like permissions or check into logs.</strong></p>