mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
nixos/nginx: make redirect status code configurable
Add an option to configure which code globalRedirect and forceSSL use. It previously was always 301 with no easy way to override.
This commit is contained in:
parent
72061433dd
commit
a3c60d2ddc
5 changed files with 51 additions and 8 deletions
|
@ -162,10 +162,11 @@ with lib;
|
|||
type = types.bool;
|
||||
default = false;
|
||||
description = lib.mdDoc ''
|
||||
Whether to add a separate nginx server block that permanently redirects (301)
|
||||
all plain HTTP traffic to HTTPS. This will set defaults for
|
||||
`listen` to listen on all interfaces on the respective default
|
||||
ports (80, 443), where the non-SSL listens are used for the redirect vhosts.
|
||||
Whether to add a separate nginx server block that redirects (defaults
|
||||
to 301, configurable with `redirectCode`) all plain HTTP traffic to
|
||||
HTTPS. This will set defaults for `listen` to listen on all interfaces
|
||||
on the respective default ports (80, 443), where the non-SSL listens
|
||||
are used for the redirect vhosts.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -307,8 +308,20 @@ with lib;
|
|||
default = null;
|
||||
example = "newserver.example.org";
|
||||
description = lib.mdDoc ''
|
||||
If set, all requests for this host are redirected permanently to
|
||||
the given hostname.
|
||||
If set, all requests for this host are redirected (defaults to 301,
|
||||
configurable with `redirectCode`) to the given hostname.
|
||||
'';
|
||||
};
|
||||
|
||||
redirectCode = mkOption {
|
||||
type = types.ints.between 300 399;
|
||||
default = 301;
|
||||
example = 308;
|
||||
description = lib.mdDoc ''
|
||||
HTTP status used by `globalRedirect` and `forceSSL`. Possible usecases
|
||||
include temporary (302, 307) redirects, keeping the request method and
|
||||
body (307, 308), or explicitly resetting the method to GET (303).
|
||||
See <https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections>.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue