title: Odd redirect to localhost instead of ip with node / express
body: <p>I try to run a node server together with nginx. With passport modul I follow the local authentication strategy. My problem is that all express redirects like '/login' lead to 'localhost:3000/login' instead 'http://:3000/login'.</p>
  
  <p>That an example function:</p>
  
  <pre><code>exports.ensureAuthenticated = function(req, res, next) {
    if (req.isAuthenticated()) { return next(); }
    res.redirect('/login');
  }
  </code></pre>
  
  <p>Even res.redirect(server+'/login') makes no difference when server is the remote ip plus port.</p>
  
  <p>Here is my nginx configuration (/etc/nginx/sites-available/default)</p>
  
  <pre><code>upstream node_app {
      server **&lt;ip&gt;**:3000;
  }
  
  server {
  
    listen 8080;
    server_name **&lt;ip&gt;**;
  
    root /home/nls/www2;
    access_log /var/log/nginx/foo.access.log;
    error_page 404 /404.html;
  
    location /remote_data/ {
  
      # Proxy request to node:
  
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-NginX-Proxy true;
  
      proxy_pass http://node_app;
      proxy_redirect off;
  
      access_log /var/log/nginx/foo_nodeapp.access.log;
  
    }
  
    location / {
      try_files $uri $uri/index.html 404;
    }
  
  }
  </code></pre>
  
  <p>The server code contains no reference to localhost redirects. Also on client side is redirect implemented without such redirects. </p>
  
  <p><strong>Edit:</strong> This the rout which makes trouble: </p>
  
  <pre><code>app.post('/login', passport.authenticate('local', { failureRedirect: 'http://&lt;ip&gt;:3000/login', failureFlash: true }), function(req, res) { res.redirect('http://**&lt;ip&gt;**:3000/vi-lab'); });
  </code></pre>