The Wayback Machine - https://web.archive.org/web/20201107174248/https://github.com/nginx-proxy/nginx-proxy/issues/967
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

[Question/Docs] `vhost.d/example.com` examples and redirects #967

Open
polarathene opened this issue Nov 5, 2017 · 1 comment
Open

[Question/Docs] `vhost.d/example.com` examples and redirects #967

polarathene opened this issue Nov 5, 2017 · 1 comment

Comments

@polarathene
Copy link

@polarathene polarathene commented Nov 5, 2017

The examples for vhost configs for server/location blocks on the README only provide settings, they don't seem to explain much about intended content/blocks.

  • Are settings for server blocks only relevant?(LetsEncrypt companion seems to insert location blocks instead of using _location file)
  • Adding location blocks in example.com_location would be nested blocks presumably or only for settings for including into a default location block by nginx-proxy?
  • Do 301 redirects and other location blocks not belong in nginx-proxy, are they advised to be handled by each separate container frontend(nginx/apache/etc) instead? If so any reason why?(while not better isolated, using nginx-proxy keeps the related configs in a consistent format and location without additional hassle of modifying various thirdparty nginx/apache configs to accomodate the inclusions), perhaps in some setups, this doesn't work well with the vhost container?
  • Is there a reason that multiple files or symlinks need to be created for a container with multiple vhost values? An env var to have nginx-proxy symlink all vhost to a config wouldn't make sense?
@kamermans
Copy link
Contributor

@kamermans kamermans commented Nov 7, 2017

Hi @polarathene, I'll try to answer your questions:

Are settings for server blocks only relevant?(LetsEncrypt companion seems to insert location blocks instead of using _location file)

If you need to insert a whole new location block, you need to do it in the server context - that's where the vhost.d file comes in. If you just want to alter the generated location block, for example, to add change the proxy_cookie_domain or increase the client_max_body_size, you could add a _location file.

Adding location blocks in example.com_location would be nested blocks presumably or only for settings for including into a default location block by nginx-proxy?

You cannot nest location blocks - it's only for altering the location generated by nginx-proxy. Note that _location is included after proxy_pass, although I'm not sure how much the order of the statements matters.

Do 301 redirects and other location blocks not belong in nginx-proxy, are they advised to be handled by each separate container frontend(nginx/apache/etc) instead? If so any reason why?(while not better isolated, using nginx-proxy keeps the related configs in a consistent format and location without additional hassle of modifying various thirdparty nginx/apache configs to accommodate the inclusions), perhaps in some setups, this doesn't work well with the vhost container?

Fundamentally, I like the idea that nginx-proxy is completely separated from your business logic, like doing redirects, etc. At my company, I have one redirect container per Docker host that handles all the redirections, place holders, etc. It runs vanilla nginx which contains its own location blocks. nginx-proxy still handles the SSL for these hosts, which is really nice.

I do have one situation where I need to modify the nginx-proxy config, and as much as I hate it, I see on clear alternative. I'm not sure I want to get into why it has to be this way, but what I can say is that I mount a new site in /etc/nginx/conf.d/<config>.conf and nginx-proxy will happily pick it up and serve it as well, so this may be an option for you too.

Is there a reason that multiple files or symlinks need to be created for a container with multiple vhost values? An env var to have nginx-proxy symlink all vhost to a config wouldn't make sense?

When you say symlink, I assume you mean that when you add a special config by mounting it in the vhosts.d directory, you also need to symlink in all the other domains listed in your VIRTUAL_HOST so it will get used for them too. I have a similar problem where I would love to say SERVER_INCLUDE=/etc/nginx/custom/foo.conf and LOCATION_INCLUDE=/etc/nginx/custom/foo_location.conf or something similar. The alternative - automatically creating symlinks for each VIRTUAL_HOST, sounds impossible considering they can be any valid nginx location, including PCRE regex expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.