summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-12-01Fixing prototype process crash.Max Romanov1-0/+2
A prototype stores linked application processes structures. When an application process terminates, it's removed from the list. To avoid double removal, the pointer to the next element should be set to NULL. The issue was introduced in c8790d2a89bb.
2021-12-01Fixing uninitialized structure field.Max Romanov1-0/+1
Port's "data" field may be used by application and thus need to be set to NULL. The issue was introduced in the f8a0992944df commit. Found by Coverity (CID 374352).
2021-12-01Logging of the daemon version on startup.Valentin Bartenev1-1/+1
2021-11-25PHP: fixed crash when calling module functions in OPcache preload.Valentin Bartenev1-2/+5
In PHP, custom fastcgi_finish_request() and overloaded chdir() functions can be invoked by an OPcache preloading script (it runs when php_module_startup() is called in the app process setup handler). In this case, there was no runtime context set so trying to access it caused a segmentation fault. This closes #602 issue on GitHub.
2021-11-25Fixing access_log structure reference counting.Max Romanov1-4/+26
The reference to the access_log structure is stored in the current nxt_router_conf_t and the global nxt_router_t. When the reference is copied, the reference counter should be adjusted accordingly. This closes #593 issue on GitHub.
2021-11-24Fixing zombie process appearance and hang up on shutdown.Max Romanov1-1/+3
After the c8790d2a89bb commit, the SIGCHLD handler may return before processing all awaiting PIDs. To avoid zombie processes and ensure successful main process termination, waitpid() must be called until an error is returned. This closes #600 issue on GitHub.
2021-11-24Fixing alerts on router restart.Max Romanov3-7/+16
Splitting the process type connectivity matrix to 'keep ports' and 'send ports'; the 'keep ports' matrix is used to clean up unnecessary ports after forking a new process, and the 'send ports' matrix determines which process types expect to get created process ports. Unfortunately, the original single connectivity matrix no longer works because of an application stop delay caused by prototypes. Existing applications should not get the new router port at the moment.
2021-11-24Sending shared port to application prototype.Max Romanov8-85/+110
Application process started with shared port (and queue) already configured. But still waits for PORT_ACK message from router to start request processing (so-called "ready state"). Waiting for router confirmation is necessary. Otherwise, the application may produce response and send it to router before the router have the information about the application process. This is a subject of further optimizations.
2021-11-23Fixed possible access to an uninitialized field.Valentin Bartenev1-3/+3
The "recv_msg.incoming_buf" is checked after jumping to the "done" label if nxt_socket_msg_oob_get_fds() returns an error. Also moved initialization of "port_msg" near to its first usage. Found by Coverity (CID 373899).
2021-11-11Removed the execute permission bit from "nxt_h1proto.c".Valentin Bartenev1-0/+0
It was accidentally added in 4645a43bc248.
2021-11-09Introducing application prototype processes.Tiago Natel de Moura14-182/+1092
2021-11-09Changed nxt_process_* for reuse.Tiago Natel de Moura7-261/+255
This enables the reuse of process creation functions.
2021-11-09Introduced SCM_CREDENTIALS / SCM_CREDS in the socket control msgs.Tiago Natel de Moura11-343/+515
2021-11-05Router: matching query string support.Zhidao HONG3-0/+51
The "query" option matches decoded arguments, including plus ('+') to space (' '). Like "uri", it can be a string or an array of strings.
2021-11-05HTTP: removed surplus check for r->args is not NULL.Zhidao HONG2-6/+2
2021-11-05Router: fixed nxt_http_route_arguments_parse().Zhidao HONG1-20/+11
A valid query string argument is a string of "key=value\[&key=value ...\]" pairs with non-empty keys. The fix removes invalid empty arguments.
2021-11-05Configuration: improved matching pattern error messages.Zhidao HONG1-22/+51
2021-11-02Improved logging of app module load errors.Valentin Bartenev1-5/+22
2021-10-28Moving request limit control to libunit.Max Romanov22-247/+264
Introducting application graceful stop. For now only used when application process reach request limit value. This closes #585 issue on GitHub.
2021-10-28Python: creating and reusing asgi_add_reader() wrapper.Max Romanov1-62/+21
2021-10-28Adding explicit app reference to nxt_router_app_port_release().Max Romanov1-11/+8
port->app field is not thread safe and should be used in main thread only. To release port after request processing, application reference should be obtained from corresponding request descriptor.
2021-10-27Fixed memleaks if PID checks fail in nxt_port_incoming_port_mmap().Valentin Bartenev1-11/+12
Memory allocated for "mem" and "mmap_handler" leaked in that case. Also removed one dead assigment of "hdr" pointer.
2021-10-26Fixed a potential descriptor leak if mmap() failed.Valentin Bartenev1-0/+1
2021-10-26Custom implementation of Base64 decoding function.Valentin Bartenev8-82/+208
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.
2021-10-12Removed unused declarations.Zhidao HONG1-4/+0
Declarations became unused after 6976d36be926. No functional changes.
2021-10-09Configuration: automatic migration to the new "share" behavior.Zhidao HONG7-46/+167
2021-10-08Fixed invalid call sequence in nxt_tls_ticket_key_callback().Artem Konev1-5/+13
The bug has been introduced in 0bca988e9541.
2021-10-04Static: removed surplus assignment.Valentin Bartenev1-1/+0
It's not needed after 69d823e5710a. Found by Clang Static Analyzer.
2021-10-04Static: fixed possible descriptor leak introduced in a946d8cd7f8c.Valentin Bartenev1-0/+1
2021-10-01Static: multiple paths in the "share" option.Zhidao HONG2-72/+196
2021-09-30Static: variables in the "share" option.Zhidao HONG2-47/+74
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" }
2021-09-28Static: variables in the "chroot" option.Zhidao HONG5-95/+269
2021-09-20Fixed WebSocket connection hang issue after listener reconfigure.Max Romanov1-29/+15
Because the configuration values were read from the listener's configuration, an established WebSocket connection was unable to work properly (i. e. stuck) if the listener was removed. The correct source of configuration values is the request config joint. This is related to issue #581 on GitHub.
2021-09-14Fixing build with glibc 2.34.Max Romanov2-11/+4
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.
2021-09-07Router: refactored variable pass.Zhidao HONG6-54/+81
Since the "pass" option supports both strings and variables, a generic nxt_var_t structure can be used in the configuration phase, and the "name" field in actions is redundant. No functional changes.
2021-09-06Var: keeping raw variable string for debug.Zhidao HONG1-75/+71
2021-08-25TLS: refactored nxt_tls_ticket_key_callback().Valentin Bartenev2-74/+51
Deduplicated code and improved style. No functional changes.
2021-08-17Added TLS session tickets support.Andrey Suvorov4-0/+419
2021-08-12Introduced the generic API nxt_buf_dummy_completion().Zhidao HONG2-11/+9
No functional changes.
2021-08-12Log: renamed related variables "log" as "_log" to prevent conflicts.Zhidao HONG1-11/+11
2021-08-12Router: client IP address replacement.Oisin Canty6-11/+282
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.
2021-08-12Introduced nxt_sockaddr_parse_optport() for addresses w/o ports.Oisin Canty3-64/+114
2021-08-09Python: fixing misprint in error message.Max Romanov1-2/+2
2021-08-05Router: fixed crash when matching an empty address pattern array.Oisin Canty1-0/+5
A crash would occur when the router tried to match an against an empty address pattern array. The following configuration was used to reproduce the issue: { "listeners": { "127.0.0.1:8082": { "pass": "routes" } }, "routes": [ { "match": { "source": [] }, "action": { "return": 200 } } ] }
2021-08-02Router: fixed segmentation fault.Zhidao HONG2-0/+8
In the case that routes or upstreams is empty and the pass option is a variable. If the resolved pass is routes or upstreams, a segment error occurred.
2021-08-03Fixed dead assignments.Max Romanov6-10/+3
Found by Clang Static Analyzer.
2021-07-29Application restart introduced.Max Romanov4-41/+344
When processing a restart request, the router sends a QUIT message to all existing processes of the application. Then, a new shared application port is created to ensure that new requests won't be handled by the old processes of the application.
2021-07-24Router: split nxt_http_app_conf_t from nxt_http_action_t.Zhidao HONG5-43/+45
No functional changes.
2021-07-26Router: renamed nxt_http_proxy_create() as nxt_http_proxy_init().Zhidao HONG3-18/+17
No functional changes.
2021-07-23Router: split nxt_http_static_conf_t from nxt_http_action_t.Zhidao HONG5-173/+198
No functional changes.