0

I'm trying to do what I would have thought was the easiest proxy directive in the world, proxying a public S3 bucket.

This is my config:

server {
    listen 80;
    listen [::]:80;

    server_name experiment.local;
    location /404.html {
      proxy_pass https://minio/bucket/404.html;
    }
    location / {
      error_page 404 = /404.html;
      proxy_pass https://minio/bucket/;
    }
}

What actually happens when fetching a page that does not exist in the bucket I get something like this from nginx:

<Error>
  <Code>NoSuchKey</Code>
  <Message>The specified key does not exist.</Message>
  <Key>index.html1</Key>
  <BucketName>visar</BucketName>
  <Resource>/bucket/index.html1</Resource>
  <RequestId>SCRUBBED</RequestId>
  <HostId>SCRUBBED</HostId>
</Error>

I've tried various variants of this but always get similar results. nginx is forwarding the HTTP return code properly so I do get a 404 (originally I got a 200 with my one-liner proxy_pass).

I know I am doing something really basic really wrong I just can't put my finger on it.

2 Answers2

0

I had a similar issue. The fix for me was the remove the trailing slash ( / ) on your proxy_pass line.

CHANGE

proxy_pass https://minio/bucket/;

TO

proxy_pass https://minio/bucket;

I believe this is because the request URL that matches your location block includes the slash ( / ). So you are proxying https://minio/bucket//something which will fail on the S3 side.

Hubert
  • 1
0
server {


    listen 80;
    listen [::]:80;

    server_name experiment.local;
    location /404.html {
      proxy_pass https://minio/bucket/404.html;
    }
    location / {
      proxy_pass https://minio/bucket/;
      proxy_intercept_errors on;
      error_page 404 = /404.html;
    }

}

Apparently ordering matters somewhat.