title: Nginx redirection to Phoenix loses authorization header
body: <p>I have a Phoenix Framework app deployed with Cloud Run with multiple clients using it.</p>
  <p>I want to move the deployment to Computer Engine because of Cloud Run background task limitation, but I don't want to force clients to update their apps (i.e. backend url).</p>
  <p>So I though I could deploy a Ngnix instance in Cloud Run that redirects everything to Compute Engine.</p>
  <p>The problem is that I use an authorization request header that does not reach Phoenix connection. I've tried it with a different server (a Python simpleserver) and it receives every header properly.</p>
  <p>So, the question is. Does Phoenix Framework filters out some request headers if they come from a  redirection?</p>
  <p>The header is:
  <code>{&quot;authorization&quot;, &quot;Bearer XXX&quot;}</code></p>
  <p>ngixn.conf is simply:</p>
  <pre><code>server {
      listen 80;
      return 301 http://0.0.0.0:4000$request_uri;
  }
  </code></pre>
  <p>An inspect of <code>conn.req_headers</code> for:</p>
  <pre><code>$curl -L --location --request GET 'http://localhost:80' \
  --header 'Content-Type: application/json' --header 'other: whatever'  \
  --header 'Authorization: Bearer XXXX' \
  --data-raw ''`
  </code></pre>
  <p>Inspection gives:</p>
  <pre><code>[
    {&quot;accept&quot;, &quot;*/*&quot;},
    {&quot;content-type&quot;, &quot;application/json&quot;},
    {&quot;host&quot;, &quot;0.0.0.0:4000&quot;},
    {&quot;other&quot;, &quot;whatever&quot;},
    {&quot;user-agent&quot;, &quot;curl/7.54.0&quot;}
  ]
  </code></pre>
  <p>If a curl directly to the Phoenix server app with:</p>
  <pre><code>curl -L --location --request GET 'http://localhost:4000' \
  --header 'Content-Type: application/json' --header 'other: whatever'  \
  --header 'Authorization: Bearer XXXX' \
  --data-raw ''`
  </code></pre>
  <p>We got:</p>
  <pre><code>[
    {&quot;accept&quot;, &quot;*/*&quot;},
    {&quot;authorization&quot;, &quot;Bearer XXXX&quot;},
    {&quot;content-length&quot;, &quot;0&quot;},
    {&quot;content-type&quot;, &quot;application/json&quot;},
    {&quot;host&quot;, &quot;localhost:4000&quot;},
    {&quot;other&quot;, &quot;whatever&quot;},
    {&quot;user-agent&quot;, &quot;curl/7.54.0&quot;}
  ]
  </code></pre>
  <p><em><strong>Edited</strong></em></p>
  <p>Python server does not receive authorization header either.</p>
  <p>Direct request to server:</p>
  <pre><code>127.0.0.1 - - [03/Nov/2020 07:22:30] &quot;GET / HTTP/1.1&quot; 200 -
  Host: localhost:4000
  User-Agent: curl/7.54.0
  Accept: */*
  Content-Type: application/json
  other: whatever
  Authorization: Bearer XXXX
  Content-Length: 0
  
  </code></pre>
  <p>Request redirected through Nginx:</p>
  <pre><code>127.0.0.1 - - [03/Nov/2020 07:22:41] &quot;GET / HTTP/1.1&quot; 200 -
  Host: 0.0.0.0:4000
  User-Agent: curl/7.54.0
  Accept: */*
  Content-Type: application/json
  other: whatever
  </code></pre>
  <p>So I guess Nginx is 'capturing' auth header and does not let it through</p>