title: Express route setup with NGINX and HTTPS?
body: <p>In short: I have the same problem as previously asked and answered within this question(<a href="https://stackoverflow.com/questions/44668559/how-to-setup-routes-with-express-and-nginx">How to setup routes with Express and NGINX?</a>) although my files look slightly different since I'm using HTTPS and I never made use of <code>try_files</code>.</p>
  
  <p><em>The normal root link works (my.website.org), but when I navigate to (my.website.com/login), I get a 404 from NGINX</em></p>
  
  <p>The sites by themselves all work perfectly fine (also when I switch out the index for the login), but as soon as I am not accessing the root link i receive the 404 :(. I already tried a couple of suggested solutions but somehow couldn't make any work for me. Maybe someone on here has a suggestion regarding my setup.</p>
  
  <hr>
  
  <p>Filestructure of my project:</p>
  
  <pre><code>my
  | - public
  | - views
  |     | - index.pug
  |     L - login.pug
  | - app.js
  L - package.json
  </code></pre>
  
  <hr>
  
  <p>First up my <strong>app.js</strong> file:</p>
  
  <pre><code>const express = require('express');
  const path = require('path');
  const bodyParser = require('body-parser');
  const app = express();
  
  // Load View Engine
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'pug');
  
  app.use(bodyParser.urlencoded({extended: false}));
  app.use(bodyParser.json());
  
  // Home Route
  app.get('/', function(req, res){res.render('index');});
  // Login Route
  app.get('/login', function(req, res){res.render('login');});
  
  // Start Server
  app.listen(3000, function(){console.log('Server started on port 3000...');});
  </code></pre>
  
  <hr>
  
  <p>Next my NGINX Configuration:</p>
  
  <pre><code>server {
      listen 80;
      server_name my.website.org;
      return 301 https://$server_name$request_uri;
  }
  
  server {
      listen 443 ssl http2;
      server_name my.website.org;
  
      access_log  /var/log/nginx/my.access.log;
      error_log   /var/log/nginx/my.error.log;
  
      location = / {
          proxy_redirect off;
          proxy_pass http://localhost:3000;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }
  
      location ~ ^/(images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|robots.txt|humans.txt|favicon.ico) {
          root /var/www/my/public;
          access_log off;
          expires max;
      }
  
      ssl_certificate /myfullchain.pem;
      ssl_certificate_key /mykey.pem;
  }
  </code></pre>