title: NGINX reverse proxy failing with 404
body: <p>I am setting up NGINX as reverse proxy.</p>
  
  <p>Details:</p>
  
  <p>nginx -v
  nginx version: nginx/1.14.0 (Ubuntu)</p>
  
  <p>The following configuration works absolutely fine:</p>
  
  <pre><code>server {
          listen 443 ssl;
          listen [::]:443 ssl;
  
          root /var/www/html;
  
          index index.html index.htm index.nginx-debian.html;
  
          server_name 172.31.1.248;
  
          ssl_certificate /home/ubuntu/SSL/self-public-key.pem;
          ssl_certificate_key /home/ubuntu/SSL/self-private-key.pem;
  
          ssl_protocols TLSv1.2 TLSv1.3;
          ssl_prefer_server_ciphers on;
  
          location / {
                  try_files $uri $uri/ =404;
          }
  
          location /pass/ {
                  proxy_pass http://172.31.1.137:8000;
          }
  }
  </code></pre>
  
  <p>However, with the upstream block, the requests fail with 404. I have tried both proxy_pass <a href="http://backend" rel="nofollow noreferrer">http://backend</a>; and proxy_pass <a href="http://backend/" rel="nofollow noreferrer">http://backend/</a>;</p>
  
  <pre><code>upstream backend {
          server 172.31.1.137:8000;
  }
  
  server {
          listen 443 ssl;
          listen [::]:443 ssl;
  
          root /var/www/html;
  
          index index.html index.htm index.nginx-debian.html;
  
          server_name 172.31.1.248;
  
          ssl_certificate /home/ubuntu/SSL/self-public-key.pem;
          ssl_certificate_key /home/ubuntu/SSL/self-private-key.pem;
  
          ssl_protocols TLSv1.2 TLSv1.3;
          ssl_prefer_server_ciphers on;
  
          location / {
                  try_files $uri $uri/ =404;
          }
  
          location /pass/ {
                  proxy_pass http://backend;
          }
  }
  </code></pre>