Skip to content

Adding S3 host option#367

Closed
dpanesso wants to merge 1 commit intoNginxProxyManager:developfrom
dpanesso:dev-s3-host
Closed

Adding S3 host option#367
dpanesso wants to merge 1 commit intoNginxProxyManager:developfrom
dpanesso:dev-s3-host

Conversation

@dpanesso
Copy link
Copy Markdown
Contributor

This PR allows to define an S3 host. We use this very often to serve static hosting from our AWS S3 buckets. It references #357.

It uses this location block to serve the S3 bucket content:

        proxy_http_version     1.1;
        proxy_set_header       Connection "";
        proxy_set_header       Authorization '';
        proxy_set_header       Host bucket.s3-website-us-east-1.amazonaws.com;
        proxy_hide_header      x-amz-id-2;
        proxy_hide_header      x-amz-request-id;
        proxy_hide_header      x-amz-meta-server-side-encryption;
        proxy_hide_header      x-amz-server-side-encryption;
        proxy_hide_header      Set-Cookie;
        proxy_ignore_headers   Set-Cookie;
        proxy_intercept_errors on;
        add_header             Cache-Control max-age=31536000;
        proxy_pass             http://bucket.s3-website-us-east-1.amazonaws.com/;

The maximum length of the forward_host variable would also have to be increased as 50 is too small.

This is what it looks like:

image

@jc21
Copy link
Copy Markdown
Member

jc21 commented Apr 14, 2020

Docker Image for build 1 is available on DockerHub as jc21/nginx-proxy-manager:github-pr-367

@jc21
Copy link
Copy Markdown
Member

jc21 commented Apr 14, 2020

Awesome stuff. Can I suggest that instead of having a switch to say "Is this an s3 host", we could simply detect that the forward_host is an s3 hostname and make the nginx inclusions at that point. This reduces the risk that someone enables the option for non-s3 hosts and vice versa.

We could just check for something like .*s3.*amazonaws\.com$

@dpanesso
Copy link
Copy Markdown
Contributor Author

That's a very interesting idea! Would be much better to auto detect for sure.

I had some time today and did dome tests, and now I am confused, because during my tests I had an error and my location block was wrong but it still worked. So, it seems AWS has changed something and doesn't require the headers or the host to be the bucket generated URL. I seems this PR won't be actually necessary. 😐

Let me confirm with some more tests and will either close the PR o adjust with your recommendations.

@apignard
Copy link
Copy Markdown

apignard commented May 6, 2020

autodetection will only work if S3 is AWS.
If you want autodetect add a way to add regex or such for add custom domain for S3 storage.
(other public cloud, on premise, private cloud etc have also S3 storage)

@jc21
Copy link
Copy Markdown
Member

jc21 commented Aug 24, 2020

Closing due to inactivity, and probably isn't required.

@jc21 jc21 closed this Aug 24, 2020
@Rustymage
Copy link
Copy Markdown

How would one go about a Minio (S3 Complaint) instance redirection to the correct URL?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants