Welcome! Log In Create A New Profile

Advanced

Serve index.html file if exists try_files + proxy_pass?

Lucas Rolff
April 30, 2017 06:46AM
Hi guys,

I have a small scenario where I have a backend (s3 compatible storage), which by default generates a directory listing overview of the files stored.
I want to be able to serve an "index.html" file if the file exists, else just proxy_pass as normally.

https://gist.github.com/lucasRolff/c7ea13305e9bff40eb6729246cd7eb39

My nginx config for somewhat reason doesn't work – or maybe it's because I misunderstand how try_files actually work.

So I have URLs such as:

minio.box.com/bucket1/
minio.box.com/bucket43253/


When I request these URL's I want nginx to check if index.html exists in the directory (it's an actual file on the filesystem) - if it does, serve this one, else go to @minio location.

For any other file within the directory, I will just go to @minio location so if I request unicorn.png it should go in @minio location as well.

Is there any decent (non-evil) way of doing this?

I assume I have to define the root directive to make try_files work, but what would I actually have to define, to make nginx use try_files for index.html *within* the specific bucket?

Thanks in advance

_______________________________________________
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: 316
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