title: nginx allow sending redirect from app to client
body: <p>I am trying to redirect a user back to my mobile-app after successful login. (linking back to the app)</p>
  <p>For this, I send a <code>307</code> response with this link: <code>exp://192.168.178.33:19000?steamId=76561198154889373</code></p>
  <p>My server code written in go looks like this:</p>
  <pre class="lang-golang prettyprint-override"><code>http.Redirect(w, r, redirectUrl+&quot;?steamId=&quot;+steamId, 307)
  </code></pre>
  <p>The <code>nginx</code> works as a reverse proxy loadbalancing to 2 Servers running the rest-API.</p>
  <p>here is the config:</p>
  <pre><code>upstream rest_api {
          server 123.456.789.123:8081 fail_timeout=10s;
          server 111.222.333.444:8081 fail_timeout=10s weight=5;
      }
  
  
          server {
               listen          443 ssl ipv6only=on;
               ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  
               server_name     example.com www.example.com;
  
               ssl_certificate /etc/nginx/ssl/chain.crt;
           ssl_certificate_key /etc/nginx/ssl/privkey.key;
  
           root /usr/share/nginx/html;
  
           location / {
                   index index.html index.htm;
           include /etc/nginx/headers/security_headers.conf;
           include /etc/nginx/headers/default_headers.conf;
               }
  
               location /hi {
                    index hi.html;
               }
  
           location ~* /notfound {
                   index not_found.html;
               }
          }
  
          server {
               listen          443 ssl;
               ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  
               server_name     api.example.com;
  
               ssl_certificate /etc/nginx/ssl/chain.crt;
           ssl_certificate_key /etc/nginx/ssl/privkey.key;
  
           location / {
                   proxy_pass https://rest_api;
           include /etc/nginx/headers/security_headers.conf;
           include /etc/nginx/headers/default_headers.conf;
               }
  
          }
  
        
      server {
          listen 80;
          listen [::]:80;
              server_name example.com;
              return 301 https://$host$request_uri;
  
      }
  
      server {
  
               listen          443 ssl;
               ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2;
               server_name     example.com;
               ssl_certificate /etc/nginx/ssl/chain.crt;
               ssl_certificate_key /etc/nginx/ssl/privkey.key;
               location ~* /notfound {
               root /usr/share/nginx/html/notfound;
                   index not_found.html;
               }
  
          }
  
  </code></pre>
  <p>When running the api without the <code>nginx</code> and accessing the <code>/login</code> route via <code>111.222.333.444:8081/login</code>, it works fine, and I get redirected. But when using the <code>nginx</code> as reverse proxy, I get this (note the title of the browser-window is <code>rest_api</code> just like the <code>upstream</code> in <code>nginx.conf</code>:</p>
  <p><a href="https://i.stack.imgur.com/4tlk3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4tlk3.png" alt="server not found response in the mobile browser" /></a></p>
  <p>How would I have to configure my <code>nginx</code> to pass the <code>307</code> response back to the App, instead of getting stuck in the upstream declaration?</p>
  <p>Thanks in advance.</p>