title: Using nginx as reverse proxy to AWS S3 bucket redirecting me to https://aws.amazon.com/s3/
body: <p>I have a nginx server used as reverse proxy to various ec2 instances. 
  Now I have a S3 bucket for static website hosting already set up for public read access and I want to put it behind nginx. 
  The static website shows up just fine when typing the endpoint of my S3 bucket in a browser.</p>
  
  <p>However, when trying to reach it from nginx, for some reason it simply redirects me to <a href="https://aws.amazon.com/s3/" rel="nofollow noreferrer">https://aws.amazon.com/s3/</a> instead of reaching the website hosted on my S3 bucket.
  I have tried many configs I found on the web to no avail.</p>
  
  <p>Below is the current configuration of the server block:</p>
  
  <pre><code> server{    
     listen 80;
     server_name _; 
     location /docs {
            resolver 8.8.8.8;
            proxy_set_header Host "mys3bucketname.s3-website.eu-central-1.amazonaws.com";
            proxy_pass http://mys3bucketname.s3-website.eu-central-1.amazonaws.com;
          }
  }
  </code></pre>