Revision tags: 1.28.0-1, 1.28.0 |
|
#
2180:f80f2e317334 |
| 06-Aug-2022 |
Alejandro Colomar |
Storing abstract sockets with @ internally.
We accept both "\u0000socket-name" and "@socket-name" as abstract unix sockets. The first one is passed to the kernel pristine, while the second is trans
Storing abstract sockets with @ internally.
We accept both "\u0000socket-name" and "@socket-name" as abstract unix sockets. The first one is passed to the kernel pristine, while the second is transformed '@'->'\0'.
The commit that added support for unix sockets accepts both variants, but we internally stored it in the same way, using "\u0000..." for both.
We want to support abstract sockets transparently to the user, so that if the user configures unitd with '@', if we receive a query about the current configuration, the user should see the same exact thing that was configured. So, this commit avoids the transformation in the internal state file, storing user input pristine, and we only transform the '@' for a string that will be used internally (not user-visible).
This commit (indirectly) fixes a small bug, where we created abstract sockets with a trailing '\0' in their name due to calling twice nxt_sockaddr_parse() on the same string. By calling that function only once with each copy of the string, we have fixed that bug.
show more ...
|
#
2166:64a3527f65ad |
| 28-Jul-2022 |
Zhidao HONG |
Log: customizable access log format.
|
#
2161:f8e608f69800 |
| 27-Feb-2022 |
Alejandro Colomar |
Supporting UNIX sockets in address matching.
This closes #645 issue on GitHub.
(Also moved a changelog line that was misplaced in a previous commit.)
|
#
2147:7bf58b1b18c4 |
| 13-Jul-2022 |
Zhidao HONG |
Var: dynamic variables support.
This commit adds the variables $arg_NAME, $header_NAME, and $cookie_NAME.
|
#
2133:46433e3cef45 |
| 20-Jun-2022 |
Zhidao HONG |
Router: forwared header replacement.
|
Revision tags: 1.27.0-1, 1.27.0 |
|
#
2108:6e059f15e713 |
| 09-Dec-2021 |
Alejandro Colomar |
Static: supporting new "index" option.
This supports a new option "index" that configures a custom index file name to be served when a directory is requested. This initial support only allows a sin
Static: supporting new "index" option.
This supports a new option "index" that configures a custom index file name to be served when a directory is requested. This initial support only allows a single fixed string. An example:
{ "share": "/www/data/static/$uri", "index": "lookatthis.htm" }
When <example.com/foo/bar/> is requested, </www/data/static/foo/bar/lookatthis.html> is served.
Default is "index.html".
===
nxt_conf_validator.c:
Accept "index" as a member of "share", and make sure it's a string.
===
I tried this feature in my own computer, where I tried the following:
- Setting "index" to "lookatthis.htm", and check that the correct file is being served (check both a different name and a different extension). - Not setting "index", and check that <index.html> is being served. - Settind "index" to an array of strings, and check that the configuration fails:
{ "error": "Invalid configuration.", "detail": "The \"index\" value must be a string, but not an array." }
show more ...
|
#
2081:c68e6afffb84 |
| 05-Apr-2022 |
Alejandro Colomar |
Supporting variables in "location".
............ Description: ............
Before this commit, the encoded URI could be calculated at configuration time. Now, since variables can only be resolved
Supporting variables in "location".
............ Description: ............
Before this commit, the encoded URI could be calculated at configuration time. Now, since variables can only be resolved at request time, we have different situations:
- "location" contains no variables:
In this case, we still encode the URI in the conf structure, at configuration time, and then we just copy the resulting string to the ctx structure at request time.
- "location" contains variables:
In this case, we compile the var string at configure time, then when we resolve it at request time, and then we encode the string.
In both cases, as was being done before, if the string is empty, either before or after resolving variables, we skip the encoding.
........... Usefulness: ...........
An example of why this feature may be useful is redirecting HTTP to HTTPS with something like:
"action": { "return": 301, "location": "https://${host}${uri}" }
..... Bugs: .....
This feature conflicts with the relevant RFCs in the following:
'$' is used for Unit variables, but '$' is a reserved character in a URI, to be used as a sub-delimiter. However, it's almost never used as that, and in fact, other parts of Unit already conflict with '$' being a reserved character for use as a sub-delimiter, so this is at least consistent in that sense. VBart suggested an easy workaround if we ever need it: adding a variable '$sign' which resolves to a literal '$'.
...... Notes: ......
An empty string is handled as if "location" wasn't specified at all, so no Location header is sent.
This is incorrect, and the code is slightly misleading.
The Location header consists of a URI-reference[1], which might be a relative one, which itself might consist of an empty string[2].
[1]: <https://www.rfc-editor.org/rfc/rfc7231#section-7.1.2> [2]: <https://stackoverflow.com/a/43338457>
Now that we have variables, it's more likely that an empty Location header will be requested, and we should handle it correctly.
I think in a future commit we should modify the code to allow differentiating between an unset "location" and an empty one, which should be treated as any other "location" string.
................. Testing (manual): .................
{ "listeners": { "*:80": { "pass": "routes/str" }, "*:81": { "pass": "routes/empty" }, "*:82": { "pass": "routes/var" }, "*:83": { "pass": "routes/enc-str" }, "*:84": { "pass": "routes/enc-var" } }, "routes": { "str": [ { "action": { "return": 301, "location": "foo" } } ], "empty": [ { "action": { "return": 301, "location": "" } } ], "var": [ { "action": { "return": 301, "location": "$host" } } ], "enc-str": [ { "action": { "return": 301, "location": "f%23o#o" } } ], "enc-var": [ { "action": { "return": 301, "location": "f%23o${host}#o" } } ] } }
$ curl --dump-header - localhost:80 HTTP/1.1 301 Moved Permanently Location: foo Server: Unit/1.27.0 Date: Thu, 07 Apr 2022 23:30:06 GMT Content-Length: 0
$ curl --dump-header - localhost:81 HTTP/1.1 301 Moved Permanently Server: Unit/1.27.0 Date: Thu, 07 Apr 2022 23:30:08 GMT Content-Length: 0
$ curl --dump-header - localhost:82 HTTP/1.1 301 Moved Permanently Location: localhost Server: Unit/1.27.0 Date: Thu, 07 Apr 2022 23:30:15 GMT Content-Length: 0
$ curl --dump-header - -H "Host: bar" localhost:82 HTTP/1.1 301 Moved Permanently Location: bar Server: Unit/1.27.0 Date: Thu, 07 Apr 2022 23:30:23 GMT Content-Length: 0
$ curl --dump-header - -H "Host: " localhost:82 HTTP/1.1 301 Moved Permanently Server: Unit/1.27.0 Date: Thu, 07 Apr 2022 23:30:29 GMT Content-Length: 0
$ curl --dump-header - localhost:83 HTTP/1.1 301 Moved Permanently Location: f%23o#o Server: Unit/1.27.0 Date: Sat, 09 Apr 2022 11:22:23 GMT Content-Length: 0
$ curl --dump-header - -H "Host: " localhost:84 HTTP/1.1 301 Moved Permanently Location: f%23o#o Server: Unit/1.27.0 Date: Sat, 09 Apr 2022 11:22:44 GMT Content-Length: 0
$ curl --dump-header - -H "Host: alx" localhost:84 HTTP/1.1 301 Moved Permanently Location: f%23oalx#o Server: Unit/1.27.0 Date: Sat, 09 Apr 2022 11:22:52 GMT Content-Length: 0
$ curl --dump-header - -H "Host: a#l%23x" localhost:84 HTTP/1.1 301 Moved Permanently Location: f%2523oa#l%2523x%23o Server: Unit/1.27.0 Date: Sat, 09 Apr 2022 11:23:09 GMT Content-Length: 0
$ curl --dump-header - -H "Host: b##ar" localhost:82 HTTP/1.1 301 Moved Permanently Location: b#%23ar Server: Unit/1.27.0 Date: Sat, 09 Apr 2022 11:25:01 GMT Content-Length: 0
show more ...
|
#
2079:0dcffa83cac2 |
| 11-Mar-2022 |
Alejandro Colomar |
Added NXT_MAYBE_UNUSED for __attribute__((__unused__)).
When testing some configurations of compilers and OSes, I noticed that clang(1) 13 on Debian caused a function to be compiled but unused, and
Added NXT_MAYBE_UNUSED for __attribute__((__unused__)).
When testing some configurations of compilers and OSes, I noticed that clang(1) 13 on Debian caused a function to be compiled but unused, and the compiler triggered a compile error.
To avoid that error, use __attribute__((__unused__)). Let's call our wrapper NXT_MAYBE_UNUSED, since it describes itself more precisely than the GCC attribute name. It's also the name that C2x (likely C23) has given to the standard attribute, which is [[maybe_unused]], so it's also likely to be more readable because of that name being in ISO C.
show more ...
|
#
2078:0996dd223cdd |
| 18-Dec-2021 |
Alejandro Colomar |
Fixed indentation.
Some lines (incorrectly) had an indentation of 3 or 5, or 7 or 9, or 11 or 13, or 15 or 17 spaces instead of 4, 8, 12, or 16. Fix them.
Found with:
$ find src -type f | xargs g
Fixed indentation.
Some lines (incorrectly) had an indentation of 3 or 5, or 7 or 9, or 11 or 13, or 15 or 17 spaces instead of 4, 8, 12, or 16. Fix them.
Found with:
$ find src -type f | xargs grep -n '^ [^ ]'; $ find src -type f | xargs grep -n '^ [^ *]'; $ find src -type f | xargs grep -n '^ [^ ]'; $ find src -type f | xargs grep -n '^ [^ *]'; $ find src -type f | xargs grep -n '^ [^ +]'; $ find src -type f | xargs grep -n '^ [^ *+]'; $ find src -type f | xargs grep -n '^ [^ +]'; $ find src -type f | xargs grep -n '^ [^ *+]';
show more ...
|
Revision tags: 1.26.1-1, 1.26.1, 1.26.0-1, 1.26.0 |
|
#
1991:61155eb41a96 |
| 05-Nov-2021 |
Zhidao HONG |
Router: matching query string support.
The "query" option matches decoded arguments, including plus ('+') to space (' '). Like "uri", it can be a string or an array of strings.
|
#
1988:574e6e17fc19 |
| 05-Nov-2021 |
Zhidao HONG |
Configuration: improved matching pattern error messages.
|
#
1975:6a47cab8f271 |
| 26-Oct-2021 |
Valentin Bartenev |
Custom implementation of Base64 decoding function.
Compared to the previous implementation based on OpenSSL, the new implementation has these advantages:
1. Strict and reliable detection of invali
Custom implementation of Base64 decoding function.
Compared to the previous implementation based on OpenSSL, the new implementation has these advantages:
1. Strict and reliable detection of invalid strings, including strings with less than 4 bytes of garbage at the end;
2. Allows to use Base64 strings without '=' padding.
show more ...
|
#
1969:be6409cdb028 |
| 09-Oct-2021 |
Zhidao HONG |
Configuration: automatic migration to the new "share" behavior.
|
#
1961:69d823e5710a |
| 01-Oct-2021 |
Zhidao HONG |
Static: multiple paths in the "share" option.
|
#
1960:a5c08e4a9946 |
| 30-Sep-2021 |
Zhidao HONG |
Static: variables in the "share" option.
This commit supports variable in the "share" option, the finding path to file serve is the value from "share". An example: { "share": "/www/data/static$u
Static: variables in the "share" option.
This commit supports variable in the "share" option, the finding path to file serve is the value from "share". An example: { "share": "/www/data/static$uri" }
show more ...
|
#
1959:45b25ffb2e8c |
| 28-Sep-2021 |
Zhidao HONG |
Static: variables in the "chroot" option.
|
#
1955:e834792ed4e3 |
| 14-Sep-2021 |
Max Romanov |
Fixing build with glibc 2.34.
Explicitly using the sysconf() call to obtain the minimum thread stack size instead of the PTHREAD_STACK_MIN macro.
This closes #576 PR on GitHub.
|
Revision tags: 1.25.0-1, 1.25.0 |
|
#
1942:296628096d6c |
| 17-Aug-2021 |
Andrey Suvorov |
Added TLS session tickets support.
|
#
1936:953434450ea9 |
| 12-Aug-2021 |
Oisin Canty |
Router: client IP address replacement.
This commit introduces the replacement of the client address based on the value of a specified HTTP header. This is intended for use when Unit is placed behin
Router: client IP address replacement.
This commit introduces the replacement of the client address based on the value of a specified HTTP header. This is intended for use when Unit is placed behind a reverse proxy like nginx or a CDN.
You must specify the source addresses of the trusted proxies. This can be accomplished with any valid IP pattern supported by Unit's match block:
["10.0.0.1", "10.4.0.0/16", "!192.168.1.1"]
The feature is configured per listener.
The client address replacement functionality only operates when there is a source IP match and the specified header is present. Typically this would be an 'X-Forwarded-For' header.
{ "listeners": { "127.0.0.1:8080": { "client_ip": { "header": "X-Forwarded-For", "source": [ "10.0.0.0/8" ] }, "pass": "applications/my_app" }, } }
If a request occurs and Unit receives a header like below:
"X-Forwarded-For: 84.123.23.23"
By default, Unit trusts the last rightmost IP in the header, so REMOTE_ADDR will be set to 84.123.23.23 if the connection originated from 10.0.0.0/8.
If Unit runs behind consecutive reverse proxies and receives a header similar to the following:
"X-Forwarded-For: 84.123.23.23, 10.0.0.254"
You will need to enable "recursive" checking, which walks the header from last address to first and chooses the first non-trusted address it finds.
{ "listeners": { "127.0.0.1:8080": { "client_ip": { "header": "X-Forwarded-For", "source": [ "10.0.0.0/8" ] "recursive": true, }, "pass": "applications/my_app" }, } }
If a connection from 10.0.0.0/8 occurs, the chain is walked. Here, 10.0.0.254 is also a trusted address so the client address will be replaced with 84.123.23.23.
If all IP addresses in the header are trusted, the client address is set to the first address in the header:
If 10.0.0.0/8 is trusted and "X-Forwarded-For: 10.0.0.3, 10.0.0.2, 10.0.0.1", the client address will be replaced with 10.0.0.3.
show more ...
|
#
1923:9f268a8a1a2f |
| 23-Jul-2021 |
Zhidao HONG |
Router: split nxt_http_static_conf_t from nxt_http_action_t.
No functional changes.
|
#
1920:7c19530e2502 |
| 21-Jul-2021 |
Andrey Suvorov |
Enabling configure TLS sessions.
To support TLS sessions, Unit uses the OpenSSL built-in session cache; the cache_size option defines the number sessions to store. To disable the feather, the optio
Enabling configure TLS sessions.
To support TLS sessions, Unit uses the OpenSSL built-in session cache; the cache_size option defines the number sessions to store. To disable the feather, the option must be zero.
show more ...
|
#
1910:b9e844d85f21 |
| 02-Jul-2021 |
Oisin Canty |
Ruby: process and thread lifecycle hooks.
This feature allows one to specify blocks of code that are called when certain lifecycle events occur. A user configures a "hooks" property on the app conf
Ruby: process and thread lifecycle hooks.
This feature allows one to specify blocks of code that are called when certain lifecycle events occur. A user configures a "hooks" property on the app configuration that points to a script. This script will be evaluated on boot and should contain blocks of code that will be called on specific events.
An example of configuration:
{ "type": "ruby", "processes": 2, "threads": 2, "user": "vagrant", "group": "vagrant", "script": "config.ru", "hooks": "hooks.rb", "working_directory": "/home/vagrant/unit/rbhooks", "environment": { "GEM_HOME": "/home/vagrant/.ruby" } }
An example of a valid "hooks.rb" file follows:
File.write("./hooks.#{Process.pid}", "hooks evaluated")
on_worker_boot do File.write("./worker_boot.#{Process.pid}", "worker booted") end
on_thread_boot do File.write("./thread_boot.#{Process.pid}.#{Thread.current.object_id}", "thread booted") end
on_thread_shutdown do File.write("./thread_shutdown.#{Process.pid}.#{Thread.current.object_id}", "thread shutdown") end
on_worker_shutdown do File.write("./worker_shutdown.#{Process.pid}", "worker shutdown") end
This closes issue #535 on GitHub.
show more ...
|
Revision tags: 1.24.0-1, 1.24.0 |
|
#
1885:09b857a2cca9 |
| 26-May-2021 |
Andrey Suvorov |
Enabling SSL_CTX configuration by using SSL_CONF_cmd().
To perform various configuration operations on SSL_CTX, OpenSSL provides SSL_CONF_cmd(). Specifically, to configure ciphers for a listener, "
Enabling SSL_CTX configuration by using SSL_CONF_cmd().
To perform various configuration operations on SSL_CTX, OpenSSL provides SSL_CONF_cmd(). Specifically, to configure ciphers for a listener, "CipherString" and "Ciphersuites" file commands are used: https://www.openssl.org/docs/man1.1.1/man3/SSL_CONF_cmd.html
This feature can be configured in the "tls/conf_commands" section.
show more ...
|
#
1883:b075f32408a1 |
| 26-May-2021 |
Oisin Canty |
Static: handled unknown MIME types when MIME-filtering active.
|
#
1879:fb89cf8544e7 |
| 25-May-2021 |
Oisin Canty |
Configuration: generalized application "targets" validation.
|