Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add direct_proxy configuration variable to allow bypassing try_files #19

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Add direct_proxy configuration variable to allow bypassing try_files #19

wants to merge 5 commits into from

Conversation

cristoper
Copy link
Contributor

This pull request aims to fix Issue #13:

  • the try_files directive falls back to the @upstream if it exists, otherwise to =404 (instead of both, which is invalid)
  • a new direct_proxy variable is introduced. When it is set to the name of an upstream, it causes ALL requests to be proxied to that upstream (so there is no try_files directive). This is preferable to try_files when the upstream is meant to handle all requests (for example, when proxying to an Apache server that handles its own static files).

In the process I moved some proxy configuration to /etc/nginx.conf.d/common_proxy.conf to reduce clutter.

(Nick, I know you're currently working on a revamp of this role. I'm mostly posting this for anybody else who is using this role, and to give you ideas while you work on the new version.)

It doesn't make sense to have an upstream followed by =404. The
@upstream parameter must be the last parameter.

http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files
When set to the name of an upstream, the direct_proxy variable causes
ALL requests to be proxied (so there is no try_file directive).

This is useful, for example, when proxying to a web server which handles
all static content or when the nginx reverse-proxy doesn't have access
to the origin server's root directory.

Example:

direct_proxy: apache
upstreams:
     - name: apache
       servers: ['apache_upstream_server']
@nickjj
Copy link
Owner

nickjj commented Feb 11, 2018

Thanks a lot for this. I will hold off on merging this one, and the revamp is still quite a ways off, so it's definitely valuable to keep this around for others.

I forgot everything in conf.d is included by the default nginx.conf
file. Better to keep our configurations separate.
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.

2 participants