title: nginx reverse proxy - how to rewrite a 303 location response header?
body: <p>I've setup my nginx reverse proxy and I can reach my internal host without issues</p>
  <p>However, it flicks back a 303 when initially connecting to push the client to authenticate.. and the location sent gets through as the internal server</p>
  <p>eg:</p>
  <pre><code>Status: 303 See Other
  Location: http://kaonashi.local.abc.com/auth/login
  </code></pre>
  <p>How can I rewrite the location header so that it is still pointing to my external address?</p>
  <p>My config is:</p>
  <pre><code>server {
          listen 443 ssl; # Make sure the 'ssl' is added here as well
  
          ssl_certificate /etc/letsencrypt/live/external.abc.com/fullchain.pem;
          ssl_certificate_key /etc/letsencrypt/live/external.abc.com/privkey.pem;
  
          # modsecurity
          modsecurity on;
          modsecurity_rules_file /etc/nginx/modsec/main.conf;
  
          root /var/www/external.abc.com/html;
          index index.html index.htm index.nginx-debian.html;
  
          server_name external.abc.com;
  
          location / {
  
                  try_files $uri $uri/ =404;
          }
  
          location /leantime/ {
  
                  proxy_set_header Host kaonashi.local.abc.com;
                  proxy_set_header X-Real-IP        $remote_addr;
                  proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                  proxy_set_header X-Forwarded-Host $host:$server_port;
                  proxy_set_header X-NginX-Proxy true;
  
                  proxy_pass http://kaonashi.local.abc.com:8080/;
          }
  }
  </code></pre>