title: Nginx reverse proxy for flask
body: <p>I'm using Flask + Gunicorn + Nginx </p>
  
  <p>I have a domain <code>example.digital</code> and a sub domain <code>api.example.digital</code></p>
  
  <p>In flask I have 3 blueprints.
  Blueprint for <code>api</code> is registered using <code>subdomain='api'</code> and I have set <code>SERVER_NAME</code> config to <code>example.digital</code></p>
  
  <p>Everything seems to be working fine on my system (Windows no gunicorn and nginx). But on my server there is a problem. I have setup 2 virtual hosts with reverse proxy. My config is as follows</p>
  
  <pre><code>server {
      listen 80;
      server_name example.digital;
  
      location / {
  
              proxy_pass http://127.0.0.1:8000$request_uri;
              proxy_set_header Host $host;
      }
  
      location /static {
              alias  /home/ubuntu/backend/codes/static;
      }
  }
  server{
      listen 80;
      server_name api.example.digital;
  
      location / {
              proxy_pass http://127.0.0.1:8000$request_uri;
              proxy_set_header Host $host;
      }
  }
  </code></pre>
  
  <p><code>api.example.digital</code> is working fine but there is a problem with main domain <code>example.digital</code>. Nothing except main page is loading. if I access <code>example.digital</code> main page loads but <code>exapmle.digital/login</code> shows 404.</p>