Welcome! Log In Create A New Profile

Advanced

Re: Serve index.html file if exists try_files + proxy_pass?

Francis Daly
May 01, 2017 08:10AM
On Mon, May 01, 2017 at 01:50:10PM +0200, Lucas Rolff wrote:

Hi there,

Thanks for the extra explanation. It is clear to me now.

> When I access https://minio.box.com/<bucket>/ Minio will generate an
> XML containin a list of objects within a specific bucket (as per S3
> API standards).
>
> Example: https://gist.github.com/lucasRolff/7a0afb95103f6c93d8bc448f5c1c35f4
>
> Since I do not want to expose this bucket object list, I want to do
> so if a bucket has the file "index.html" that it will serve this,
> instead of showing the bucket object list.

Ok.

For info: that *will* expose the bucket object list if there is no
index.html.

You may prefer a static fallback page, or an error indication instead.

> If I access https://minio.box.com/images/ - it should look for the
> file /home/minio/images/index.html and serve if existing else load
> the bucket object list (basically, just proxy_pass as normal).
>
> Any other request I do such as
> https://minio.box.com/images/nginx-rocks.png should go to my
> upstream server (localhost:9000)

> If I do try_files index.html @upstream;
>
> Then try_files will base it on the root directive defined, in this
> case it would try look for /home/minio/index.html if I set the root
> directive to "/home/minio", correct?

Correct.

> I guess I could take try_files "${uri}index.html" @upstream; which
> would produce something like /home/minio/storage/index.html if you
> have /storage/ as the URI, but if URI is /storage/image1.png it
> would try to look for "/home/minio/storage/image1.pngindex.html" and
> for me that doesn't seem very efficient, since it would have to stat
> for a file on the file system for every request before actually
> going to my upstream.

Also correct.

> I could maybe do:
>
> location / {
> location ~ /$ {
> try_files "${uri}index.html" @upstream;
>
> }
>
> // continue normal code here
> }
>
> location @upstream {
> proxy_pass http://127.0.0.1:9000;
> }

That is what I would suggest. Where "// continue normal code here" is
"proxy_pass http://127.0.0.1:9000;". And "root /home/minio;" is set
somewhere so that it applies where try_files is.

Good luck with it,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Serve index.html file if exists try_files + proxy_pass?

Lucas Rolff April 30, 2017 06:46AM

Re: Serve index.html file if exists try_files + proxy_pass?

Francis Daly May 01, 2017 07:20AM

Re: Serve index.html file if exists try_files + proxy_pass?

Lucas Rolff May 01, 2017 07:52AM

Re: Serve index.html file if exists try_files + proxy_pass?

Francis Daly May 01, 2017 08:10AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 282
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready