1# This file defines the options that can be used both for the Nginx
2# main server configuration, and for the virtual hosts. (The latter
3# has additional options that affect the web server as a whole, like
4# the user/group to run under.)
5
6{ lib, config }:
7
8with lib;
9
10{
11 options = {
12 basicAuth = mkOption {
13 type = types.attrsOf types.str;
14 default = { };
15 example = literalExpression ''
16 {
17 user = "password";
18 };
19 '';
20 description = ''
21 Basic Auth protection for a vhost.
22
23 WARNING: This is implemented to store the password in plain text in the
24 Nix store.
25 '';
26 };
27
28 basicAuthFile = mkOption {
29 type = types.nullOr types.path;
30 default = null;
31 description = ''
32 Basic Auth password file for a vhost.
33 Can be created by running {command}`nix-shell --packages apacheHttpd --run 'htpasswd -B -c FILENAME USERNAME'`.
34 '';
35 };
36
37 proxyPass = mkOption {
38 type = types.nullOr types.str;
39 default = null;
40 example = "http://www.example.org/";
41 description = ''
42 Adds proxy_pass directive and sets recommended proxy headers if
43 recommendedProxySettings is enabled.
44 '';
45 };
46
47 proxyWebsockets = mkOption {
48 type = types.bool;
49 default = false;
50 example = true;
51 description = ''
52 Whether to support proxying websocket connections with HTTP/1.1.
53 '';
54 };
55
56 uwsgiPass = mkOption {
57 type = types.nullOr types.str;
58 default = null;
59 example = "unix:/run/example/example.sock";
60 description = ''
61 Adds uwsgi_pass directive and sets recommended proxy headers if
62 recommendedUwsgiSettings is enabled.
63 '';
64 };
65
66 index = mkOption {
67 type = types.nullOr types.str;
68 default = null;
69 example = "index.php index.html";
70 description = ''
71 Adds index directive.
72 '';
73 };
74
75 tryFiles = mkOption {
76 type = types.nullOr types.str;
77 default = null;
78 example = "$uri =404";
79 description = ''
80 Adds try_files directive.
81 '';
82 };
83
84 root = mkOption {
85 type = types.nullOr types.path;
86 default = null;
87 example = "/your/root/directory";
88 description = ''
89 Root directory for requests.
90 '';
91 };
92
93 alias = mkOption {
94 type = types.nullOr types.path;
95 default = null;
96 example = "/your/alias/directory";
97 description = ''
98 Alias directory for requests.
99 '';
100 };
101
102 return = mkOption {
103 type =
104 with types;
105 nullOr (oneOf [
106 str
107 int
108 ]);
109 default = null;
110 example = "301 http://example.com$request_uri";
111 description = ''
112 Adds a return directive, for e.g. redirections.
113 '';
114 };
115
116 fastcgiParams = mkOption {
117 type = types.attrsOf (types.either types.str types.path);
118 default = { };
119 description = ''
120 FastCGI parameters to override. Unlike in the Nginx
121 configuration file, overriding only some default parameters
122 won't unset the default values for other parameters.
123 '';
124 };
125
126 extraConfig = mkOption {
127 type = types.lines;
128 default = "";
129 description = ''
130 These lines go to the end of the location verbatim.
131 '';
132 };
133
134 priority = mkOption {
135 type = types.int;
136 default = 1000;
137 description = ''
138 Order of this location block in relation to the others in the vhost.
139 The semantics are the same as with `lib.mkOrder`. Smaller values have
140 a greater priority.
141 '';
142 };
143
144 recommendedProxySettings = mkOption {
145 type = types.bool;
146 default = config.services.nginx.recommendedProxySettings;
147 defaultText = literalExpression "config.services.nginx.recommendedProxySettings";
148 description = ''
149 Enable recommended proxy settings.
150 '';
151 };
152
153 recommendedUwsgiSettings = mkOption {
154 type = types.bool;
155 default = config.services.nginx.recommendedUwsgiSettings;
156 defaultText = literalExpression "config.services.nginx.recommendedUwsgiSettings";
157 description = ''
158 Enable recommended uwsgi settings.
159 '';
160 };
161 };
162}