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

Nginx alias directive #23672

Merged
merged 3 commits into from Mar 21, 2017
Merged

Nginx alias directive #23672

merged 3 commits into from Mar 21, 2017

Conversation

edanaher
Copy link
Contributor

@edanaher edanaher commented Mar 9, 2017

Motivation for this change

While it's easy enough to add extraConfig = "alias = ${alias};", why not make it even easier?

For example, I'm using this to serve a robots.txt straight from pkgs.writeText; that's a really neat trick. With the "root" directive, this doesn't work because nginx will look for ${robots.txt}/robots.txt; with alias, it serves the file path with no modification.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Evan Danaher added 2 commits March 9, 2017 13:02
It's like root, but doesn't keep the prefix.
If both are set, nginx won't start.  More error checking is certainly in
order, but this seems like a reasonable start.
@mention-bot
Copy link

@edanaher, thanks for your PR! By analyzing the history of the files in this pull request, we identified @globin, @domenkozar and @fadenb to be potential reviewers.

@edanaher edanaher changed the title Nginx alias Nginx alias directive Mar 9, 2017
@@ -158,6 +158,7 @@ let
server_name ${serverName} ${concatStringsSep " " vhost.serverAliases};
${acmeLocation}
${optionalString (vhost.root != null) "root ${vhost.root};"}
${optionalString (vhost.alias != null) "alias ${vhost.alias};"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked whether alias works in a server? According to the docs, it should only work in location blocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh; I thought I tested it, but I must have missed something. That bit is now removed.

@fpletz fpletz added this to the 17.03 milestone Mar 9, 2017
@fpletz
Copy link
Member

fpletz commented Mar 9, 2017

This is a nice addition we can IMHO safely backport to 17.03. /cc @globin

@domenkozar domenkozar merged commit 02129a8 into NixOS:master Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants