Search notes:

nginx

Installing

APT based systems (Ubuntu, Debian, …)

$ sudo apt install -y nginx

Starting/stopping nginx (etc.)

Check if nginx is running:
$ systemctl status nginx
$ sudo ss -plntu | grep nginx
$ sudo systemctl start nginx
$ sudo systemctl stop nginx
$ sudo systemctl restart nginx
Without systemd?
# /usr/sbin/nginx -s stop
# systemctl status nginx

Reload configuration

Check if configuration is ok and only then restart server:
$ sudo nginx -t && sudo nginx -s reload

Digging into the source code

auto/configure

auto/configure is used in place of the traditional ./configure to configure the options with which nginx will be compiled.
The set of configurable options is documented here.
The very first thing that auto/configure does is to call auto/options.
The options passed to auto/configure can be queried by calling nginx with the -V command line option.

auto/options

auto/options contains a list of shell variables which correspond to configurable options.
Some variables are assigned default values, for example HTTP_SSL=NO or HTTP_REWRITE=YES.
The variable CC is set to cc unless $CC is already set.
The script iterates over all arguments given to auto/configure and replaces the default values with the ones specified when auto/configure is called, for example like so:
./auto/configure \
   --without-http_rewrite_module \
   --with-http_ssl_module
The user specified configuration values are first accumulated into $opt and then assigned to NGX_CONFIGURE.
This value is written as preprocessor macro #define NGX_CONFIGURE into the file whose value is stored in $NGX_AUTO_CONFIG_H (typically objs/ngx_auto_config.h) and can be displayed with the command line option -V:
$ objs/nginx -V 2>&1 | grep 'configure arguments'
…
configure arguments: --without-http_rewrite_module --with-http_ssl_module

auto/init

auto/init is the second script that is called from auto/configure.
This script defines the paths of the following files which are all found under $NGX_OBJS:
auto/init also sets the variable NGX_AUTOTEST to $NGX_OBJS/autotest.
The value of this variable is prominently used in auto/feature but also in other tests such as auto/types/uintptr_t etc.

auto/cc/conf

auto/cc/conf specifies options (etc.?) with which the compiler is invoked.
auto/cc/conf sources auto/cc/name which, depending on the compiler this script finds, sets the variable NGX_CC_NAME, for example to the value gcc in the case of the GNU compiler.
Depending on the value of NGX_CC_NAME, the script then sources auto/cc/gcc, auto/cc/icc, auto/cc/msvc etc.
auto/cc/conf is called from auto/configure.

auto/cc/<compiler>

auto/cc/<compiler> (such as for example auto/cc/gcc) seem to basically set variables like CFLAGS.
Interestingly auto/cc/gcc sets -g.

auto/have

auto/have adds a «have» directive to $NGX_AUTO_CONFIG_H (typically objs/ngx_auto_config.h).
The script is intended to be called like so:
have=NGX_HAVE_EPOLL . auto/have
This invocation would add the following to $NGX_AUTO_CONFIG_H:
#ifndef NGX_HAVE_EPOLL
#define NGX_HAVE_EPOLL  1
#endif

ngx_array_t

Defined in src/core/ngx_array.h.
elts is a pointer to the elements of the array.
nelts stores the number of the elements in the array.

obj/ngx_modules.c

obj/ngx_modules.c is a generated file.
auto/init sets the variable $NGX_MODULES_C to obj/ngx_modules.c.
auto/make sets the variable ngx_modules_c from $NGX_MODULES_C (by replacing / with either a forward or backward slash, depending on the environment).
It then iterates three times over the elements of the $ngx_module_modules array and writes into obj/ngx_modules.c.
The produced file contains an array, named ngx_modules of pointers to ngx_module_t, such as
ngx_module_t *ngx_modules[] = {
    &ngx_core_module,
    &ngx_errlog_module,
    &ngx_conf_module,
    &ngx_openssl_module,
     …
    NULL
};
src/core/ngx_module.c iterates over the elements in ngx_modules and sets each module's index and name.
ngx_cycle_modules() creates a list of modules.

Modules

There are a few module types:
  • CORE
  • HTTP
  • HTTP_FILTER
  • HTTP_INIT_FILTER
  • MAIL
  • STREAM
  • MISC
The variable DYNAMIC_MODULES
For each module that needs to be added, auto/modules sets a few variables an then calls auto/module.

auto/module

As far as I can tell, auto/module is only called from auto/modules.
auto/module expects the following variables to be set (possibly to an empty value):
$ngx_module_type CORE, HTTP, HTTP_FILTER, HTTP_INIT_FILTER, MAIL, STREAM, MISC
$ngx_module_name
$ngx_module_incs The name of a directory.
$ngx_module_deps
$ngx_module_srcs The (relative) path to a .c file.
$ngx_module_libs
$ngx_module_link

auto/feature

auto/feature checks if the compiler supports a given feature.
When sourced, the script expects the following variables to be set (possibly to an empty value):
ngx_feature
ngx_feature_name An identifier such as NGX_HAVE_EPOLL, NGX_HAVE_GEOIP_V6 or NGX_PCRE.
ngx_feature_run yes, bug, value have a specific meaning. no is indicated as absence (but any other value can be chosen)
ngx_feature_incs Additional includes required for the test.
ngx_feature_path
ngx_feature_libs
ngx_feature_test
In essence, the script creates a C file ($NGX_AUTOTEST.c) with the following content, compiles and executes it:
#include <sys/types.h>
$NGX_INCLUDE_UNISTD_H
$ngx_feature_incs

int main(void) {
    $ngx_feature_test;
    return 0;
}
The result of the test is either written to $NGX_AUTO_CONFIG_H using auto/have (ngx_feature_run != value (especially yes or value)) or directly (ngx_feature_run = value).
The output of stdout and stderr is appended to $NGX_AUTOCONF_ERR
auto/feature is sourced from
  • auto/unix
  • auto/cc/conf
  • auto/cc/gcc
  • auto/cc/name
  • auto/lib/google-perftools/conf
  • auto/lib/zlib/conf
  • auto/lib/pcre/conf
  • auto/lib/openssl/conf
  • auto/lib/libatomic/conf
  • auto/lib/geoip/conf
  • auto/lib/libgd/conf
  • auto/lib/libxslt/conf
  • auto/os/linux
  • auto/os/darwin
  • auto/os/solaris

main()

The main() function is defined in src/core/nginx.c.
Among others, main() calls

Configuration

struct ngx_command_s defines a configuration directive and associates a configuration name with a call back function (such as for example ngx_set_worker_processes) that processes the configuration directive when encountered
ngx_core_commands is an array of ngx_command_t objects.
The association of names to the call back functions is done when it is initialized (see for example here).
Similarly to ngx_core_commands, there is also the variable ngx_http_core_commands which takes care of configuration options such as listen.
Each config option is associated with a callback function which is assigned to the member set of the ngx_command_s struct.
In the case of listen, this callback function is ngx_http_core_listen which is called «indirectly» from here.
struct ngx_conf_s (typedefd to ngx_conf_t) …
ngx_get_options() parses command line options.
main -> ngx_init_cycle -> ngx_conf_parse -> ngx_conf_handler

struct ngx_command_s

ngx_command_s is typedefd to ngx_command_t.
Noteable members
  • name
  • type
  • set

ngx_get_options

ngx_get_options() is called from main() and parses command line options, such as for example -p <prefix-dir>.

ngx_conf_parse

ngx_conf_parse (src/core/ngx_conf_file.c) is called from different places, such as
  • main() -> ngx_init_cycle() -> ngx_conf_param()(here, where no filename is passed).
  • main() -> ngx_init_cycle() -> (here, where a filename is passed).
  • main() -> ngx_init_cycle() -> ngx_conf_parse() -> ngx_conf_handler() -> ngx_events_block()
  • main() -> ngx_init_cycle() -> ngx_conf_parse() -> ngx_conf_handler() -> ngx_http_block()

ngx_conf_read_token

NGX_OK A config option, such as listen 8080; or worker_processes auto;
NGX_CONF_BLOCK_START The token is the name of a «named block», for example http { or server {
NGX_CONF_BLOCK_DONE The terminating } of a «named block»
NGX_CONF_FILE_DONE The end
NGX_ERROR

ngx_ssl_init()

ngx_ssl_init(), called by main(), is the function that calls SSL_library_init().

struct ngx_str_s

struct ngx_str_s has the two members
  • len and
  • data

struct ngx_buf_s / ngx_buf_t

struct ngx_buf_s is used for I/O operations.

struct ngx_chain_s

ngx_chain_s seems to represent a node in a linked list of ngx_buf_s elements.

ngx_bufs_t

HTTP/Connections etc.

ngx_epoll_process_events calls ngx_event_accept.
ngx_event_accept calls ngx_http_init_connection.
A function pointer to ngx_http_init_connection is assigned to ls->handler in ngx_http_add_listening (ls being an instance of ngx_listening_t returned by ngx_http_add_listening).

ngx_socket_t

ngx_socket_t is typedefd as int (src/os/unix/ngx_socket.h or SOCKET (src/os/win32/ngx_socket.h).

struct ngx_cycle_s / ngx_cycle_t

Noteable members
Wow, conf_ctx is a pointer to a pointer to a pointer to a pointer to void.

nxg_cycle

ngx_cycle is a volatile global pointer to ngx_cycle_t.
This global object is shared(?) (documentation: «inherited») by nginx workers as they start.

struct ngx_pool_s

ngx_http_conf_port_t

Defined in src/http/ngx_http_core_module.h.

ngx_socket

ngx_socket is defined in src/os/unix/ngx_socket.h and src/os/win32/ngx_socket.h.
This macro is used for example in

ngx_http_output_body_filter_pt / ngx_http_top_body_filter, ngx_http_top_header_filter

typedef for a function pointer taking an ngx_http_request_t and an ngx_chain_t and returning an ngx_int_t.
ngx_http_top_body_filter is a variable whose type is ngx_http_output_body_filter_pt
The ngx_http_write_filter_module assigns ngx_http_write_filter to ngx_http_top_body_filter.
Simlarly also for ngx_http_top_header_filter.

ngx_http_write_filter_module

The ngx_http_write_filter_module writes data to the client socket.

ngx_http_output_filter()

ngx_http_output_filter() essentially calls ngx_http_top_body_filter().

ngx_event_accept()

ngx_get_connection()

ngx_http_init_connection

ngx_http_init_connection is the function that seems to be called when a new HTTP request was accepted.

ngx_http_core_run_phases()

… called after the request header is read.
This function runs the request phases NGX_HTTP_POST_READ_PHASE through NGX_HTTP_CONTENT_PHASE

ngx_http_finalize_request()

ngx_http_writer()

ngx_http_finalize_connection()

struct ngx_listening_s / ngx_listening_t

Some interesting members include:
The member handler is set to

struct ngx_connection_s / ngx_connection_t

struct ngx_connection_s in src/core/ngx_connection.h and the corresponding typedef struct ngx_connection_s ngx_connection_t; in src/core/ngx_core.h.
Noteable members:
  • data (TODO: see here)
  • fd (which is an ngx_socket_t)
  • read and write (which are ngx_event_t)
  • recv and send
  • ssl (compare with ssl in ngx_http_connection_t).
  • listening (an ngx_listening_s which has the member connection which points to a ngx_connection_s)
  • send_chain and recv_chain (whose type is ngx_send_chain_pt and ngx_recv_chain_pt). It seems that these function pointers point to functions (like ngx_send_chain or ngx_ssl_send_chain?) that actually read or write data from a socket.
A function that matches ngx_connection_handler_pt takes an ngx_connection_t as argument.

struct ngx_ssl_connection_s / ngx_ssl_connection_t

Noteable members:
  • session_ctx, a pointer to SSL_CTX, compare with the member ctx of ngx_ssl_s.
  • handler, a ngx_connection_handler_pt
  • session, a pointer to a ngx_ssl_session_s

struct ngx_ssl_s

Noteable members:
  • ctx, a pointer to SSL_CTX, compare with the member session_ctx of ngx_ssl_connection_s
  • certs

ngx_ssl_write()

ngx_ssl_write() is the function that calls SSL_write().

ngx_http_connection_t

Noteable members:

struct ngx_module_s / ngx_module_t

Each module is described by a ngx_module_s.
Noteable members:
  • name
  • type, one of NGX_CORE_MODULE, NGX_EVENT_MODULE, NGX_HTTP_MODULE, NGX_MAIL_MODULE, NGX_STREAM_MODULE
  • commands
  • ctx, a pointer to the module's private data
  • commands, apointer to an ngx_command_t (array) which contains the module's configuration directives
  • init_xxx, exit_xxx
See also:
  • ngx_count_modules()

ngx_event_module_t

typedef struct { … } ngx_event_module_t. (Note: there is no named struct ngx_event_module_s).
Noteable members:
  • actions which is an ngx_event_actions_t.

ngx_event_actions_t

All members are function pointers:
ngx_int_t  (*add           )(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags);
ngx_int_t  (*del           )(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags);
ngx_int_t  (*enable        )(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags);
ngx_int_t  (*disable       )(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags);
ngx_int_t  (*add_conn      )(ngx_connection_t *c);
ngx_int_t  (*del_conn      )(ngx_connection_t *c, ngx_uint_t flags);
ngx_int_t  (*notify        )(ngx_event_handler_pt handler);
ngx_int_t  (*process_events)(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags);
ngx_int_t  (*init          )(ngx_cycle_t *cycle, ngx_msec_t timer);
void       (*done          )(ngx_cycle_t *cycle);

ngx_connection_handler_pt

ngx_connection_handler_pt is found as
  • the member handler in ngx_listening_s (which handles accepted connections).
  • the member handler in ngx_ssl_connection_s
  • the member save_session in ngx_ssl_connection_s

ngx_create_listening

ngx_create_listening returns an ngx_listening_t * object.
This function is defined in src/core/ngx_connection.c.
main -> ngx_init_cycle -> ngx_conf_parse -> ngx_conf_handler -> ngx_http_block -> ngx_http_optimize_servers -> ngx_http_init_listening -> ngx_http_add_listening -> ngx_create_listening

ngx_ssl_create_connection

ngx_ssl_create_connection is the function that

ngx_http_create_request

ngx_http_create_request returns a pointer to a ngx_http_request_t.

ngx_http_ssl_handshake

struct ngx_http_addr_conf_s

ngx_http_alloc_request

ngx_http_create_request returns a pointer to ngx_http_request_t (as does also ngx_http_create_request).
Misc observations:

ngx_http_request_handler

ngx_http_request_handler takes a pointer to ngx_event_t and returns void.

ngx_http_keepalive_handler

struct ngx_http_request_s / ngx_http_request_t

Notable members:
A pointer to ngx_http_request_t is returned by ngx_http_create_request.

ngx_http_headers_in_t

ngx_http_headers_out_t

ngx_http_core_main_conf_t

Noteable members:
  • servers
  • phases, an array of ngx_http_phase_t
  • phase_engine

ngx_http_phase_t

ngx_http_phase_t which is essentially an array of handlers.

ngx_http_phases

ngx_http_phases is an enum with the following items:
NGX_HTTP_POST_READ_PHASE
NGX_HTTP_SERVER_REWRITE_PHASE
NGX_HTTP_FIND_CONFIG_PHASE
NGX_HTTP_POST_REWRITE_PHASE
NGX_HTTP_PREACCESS_PHASE
NGX_HTTP_ACCESS_PHASE
NGX_HTTP_POST_ACCESS_PHASE
NGX_HTTP_PRECONTENT_PHASE
NGX_HTTP_CONTENT_PHASE This is the (imho) interesting phase where the response is generated.
NGX_HTTP_LOG_PHASE
The phases NGX_HTTP_POST_READ_PHASE through NGX_HTTP_CONTENT_PHASE are run by ngx_http_core_run_phases().
ngx_http_init_phase_handlers iterates over each «handler type» and seems to initialize a «checker» function.

NGX_HTTP_CONTENT_PHASE - ngx_http_static_module

A prominent module that us used in the NGX_HTTP_CONTENT_PHASE is ngx_http_static_module which is initialized in ngx_http_static_init.
This module's handler is ngx_http_static_handler.

See also

See also the Nginx documentation

ngx_time_update()

ngx_time_update() sets ngx_current_msec etc.

ngx_event_expire_timers()

ngx_os_io_t

ngx_os_io_t seems to be a platform dependent struct to store function pointers for sending and receiving functions (src/os/unix/ngx_os.h and src/os/win32/ngx_os.h).
src/core/ngx_connection.c defines the variable ngx_io of type ngx_os_io_t.
ngx_linux_io (whose type is ngx_os_io_t).
src/event/ngx_event.h defines macros such as ngx_recv for ngx_io.recv etc.

ngx_unix_recv

ngx_http_read_request_header

struct ngx_event_s / ngx_event_t

struct ngx_event_s in src/event/ngx_event.h and the corresponding typedef struct ngx_event_s ngx_event_t in src/core/ngx_core.h.
Noteable members:
  • data
  • handler (which is an ngx_event_handler_pt)
  • timer (which is an ngx_rbtree_node_t)
A function that matches ngx_event_handler_pt takes an ngx_event_t as argument.

struct ngx_rbtree_s / ngx_rbtree_t

A struct ngx_rbtree_s has the members
  • root (a ngx_rbtree_node_t)
  • sentinel (a ngx_rbtree_node_t)
  • insert (a ngx_rbtree_insert_pt)
A somewhat important rb tree is ngx_event_timer_rbtree

struct ngx_rbtree_node_s / ngx_rbtree_node_t

ngx_event_handler_pt

ngx_event_handler_pt is found, among others, in
TODO 1 and TODO 2.

ngx_http_event_handler_pt

ngx_http_process_request

ngx_http_process_request receives a pointer to an ngx_http_request_t and returns void.

ngx_http_process_request_uri

ngx_http_parse_complex_uri

ngx_http_handler

processes

The number of worker processes can be specified with the configuration directive worker_process (whose value can be set to auto).

ngx_master_process_cycle()

ngx_master_process_cycle is the master process.
It
  • reads the configuration file,
  • creates cycles, and
  • starts and controls child processes.
It does not perform any I/O and responds only to signals.

epoll

Part of the initialization of nginx seems to be to check if calling epoll_create() is successfull and depending on the result to set the event module.
The «real» epoll file descriptor is created in ngx_epoll_init.
This file descriptor is assigned to the «per-process» global variable ep.

ngx_process_events

ngx_process_events is a macro that is defined as ngx_event_actions.process_events.
This macro is used in ngx_process_events_and_timers.
With epoll, this calls ngx_epoll_process_events().

ngx_epoll_process_events()

ngx_epoll_process_events() is the function that calls epoll_wait.
Note that the function ngx_epoll_process_events has the parameter timer which corresponds to the next timer event as found in the ngx_event_timer_rbtree and is passed to epoll_wait.

ngx_worker_process_init

unix and win32?

ngx_event_process_init

Observations:

ngx_event_timer_init

ngx_event_timer_init() initializes the ngx_event_timer_rbtree.

ngx_worker_process_cycle

Unix and Win32.

ngx_process_events_and_timers()

ngx_process_events_and_timers is the nginx event loop.
Notable functions that are called from ngx_process_events_and_timers include
  • ngx_event_find_timer() (if ngx_timer_resolution is false)
  • ngx_process_events()
  • ngx_event_expire_timers()

ngx_event_find_timer()

ngx_event_find_timer() finds the «next» point in time stored in ngx_event_timer_rbtree and returns the time left until that timer expires, or NGX_TIMER_INFINITE if no timer event is outstanding.
The returned value is 0 for already expired timers (return (timer > 0 ? timer : 0)).
The returned value will eventually be passed to epoll_wait (if epoll is used), see ngx_epoll_process_events().

ngx_add_timer / ngx_event_add_timer

src/event/ngx_event.h defines ngx_add_timer to be ngx_event_add_timer.
ngx_event_add_timer is defined in src/event/ngx_event_timer.h.

Configuration variables

--with-cc= PATH CC ${CC:-cc} set C compiler pathname
--with-cpp= PATH CPP set C preprocessor pathname
--with-cpu-opt= CPU CPU NO build for the specified CPU, valid values: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, sparc32, sparc64, ppc64
--add-dynamic-module= PATH DYNAMIC_ADDONS enable dynamic external module
DYNAMIC_MODULES
DYNAMIC_MODULES_SRCS
EVENT_FOUND NO
--with-poll_module EVENT_POLL NO enable poll module
--without-poll_module EVENT_POLL NO disable poll module
--with-select_module EVENT_SELECT NO enable select module
--without-select_module EVENT_SELECT NO disable select module
--without-http HTTP YES disable HTTP server It seems to me that this option is intended to be used if nginx is used as proxy (reverse proxy, mail proxy or tcp/udp proxy) or as load balancer.
--without-http_access_module HTTP_ACCESS YES disable ngx_http_access_module
--with-http_addition_module HTTP_ADDITION NO enable ngx_http_addition_module
--without-http_auth_basic_module HTTP_AUTH_BASIC YES disable ngx_http_auth_basic_module
--with-http_auth_request_module HTTP_AUTH_REQUEST NO enable ngx_http_auth_request_module
--without-http_autoindex_module HTTP_AUTOINDEX YES disable ngx_http_autoindex_module
--without-http_browser_module HTTP_BROWSER YES disable ngx_http_browser_module
--without-http-cache HTTP_CACHE YES disable HTTP cache
--without-http_charset_module HTTP_CHARSET YES disable ngx_http_charset_module
--with-http_dav_module HTTP_DAV NO enable ngx_http_dav_module
--with-http_degradation_module HTTP_DEGRADATION NO enable ngx_http_degradation_module
--without-http_empty_gif_module HTTP_EMPTY_GIF YES disable ngx_http_empty_gif_module
--without-http_fastcgi_module HTTP_FASTCGI YES disable ngx_http_fastcgi_module
--with-http_flv_module HTTP_FLV NO enable ngx_http_flv_module
--without-http_geo_module HTTP_GEO YES disable ngx_http_geo_module
--with-http_geoip_module HTTP_GEOIP NO enable ngx_http_geoip_module
--with-http_geoip_module= dynamic HTTP_GEOIP NO enable dynamic ngx_http_geoip_module
--without-http_grpc_module HTTP_GRPC YES disable ngx_http_grpc_module
--with-http_gunzip_module HTTP_GUNZIP NO enable ngx_http_gunzip_module
--without-http_gzip_module HTTP_GZIP YES disable ngx_http_gzip_module
--with-http_gzip_static_module HTTP_GZIP_STATIC NO enable ngx_http_gzip_static_module
--with-http_image_filter_module HTTP_IMAGE_FILTER NO enable ngx_http_image_filter_module
--with-http_image_filter_module= dynamic HTTP_IMAGE_FILTER NO enable dynamic ngx_http_image_filter_module
--without-http_limit_conn_module HTTP_LIMIT_CONN YES disable ngx_http_limit_conn_module
--without-http_limit_req_module HTTP_LIMIT_REQ YES disable ngx_http_limit_req_module
--without-http_map_module HTTP_MAP YES disable ngx_http_map_module
--without-http_memcached_module HTTP_MEMCACHED YES disable ngx_http_memcached_module
--without-http_mirror_module HTTP_MIRROR YES disable ngx_http_mirror_module
--with-http_mp4_module HTTP_MP4 NO enable ngx_http_mp4_module
--with-http_perl_module HTTP_PERL NO enable ngx_http_perl_module
--with-http_perl_module= dynamic HTTP_PERL NO enable dynamic ngx_http_perl_module
--without-http_proxy_module HTTP_PROXY YES disable ngx_http_proxy_module
--with-http_random_index_module HTTP_RANDOM_INDEX NO enable ngx_http_random_index_module
--with-http_realip_module HTTP_REALIP NO enable ngx_http_realip_module
--without-http_referer_module HTTP_REFERER YES disable ngx_http_referer_module
--without-http_rewrite_module HTTP_REWRITE YES disable ngx_http_rewrite_module The ngx_http_rewrite_module depends on the PCRE library. Thus, this flag might be used if PCRE is not available.
--without-http_scgi_module HTTP_SCGI YES disable ngx_http_scgi_module
--with-http_secure_link_module HTTP_SECURE_LINK NO enable ngx_http_secure_link_module
--with-http_slice_module HTTP_SLICE NO enable ngx_http_slice_module
--without-http_split_clients_module HTTP_SPLIT_CLIENTS YES disable ngx_http_split_clients_module
--without-http_ssi_module HTTP_SSI YES disable ngx_http_ssi_module
--with-http_ssl_module HTTP_SSL NO enable ngx_http_ssl_module
--without-http_status_module HTTP_STATUS
--with-http_stub_status_module HTTP_STUB_STATUS NO enable ngx_http_stub_status_module
--with-http_sub_module HTTP_SUB NO enable ngx_http_sub_module
--without-http_upstream_hash_module HTTP_UPSTREAM_HASH YES disable ngx_http_upstream_hash_module
--without-http_upstream_ip_hash_module HTTP_UPSTREAM_IP_HASH YES disable ngx_http_upstream_ip_hash_module
--without-http_upstream_keepalive_module HTTP_UPSTREAM_KEEPALIVE YES disable ngx_http_upstream_keepalive_module
--without-http_upstream_least_conn_module HTTP_UPSTREAM_LEAST_CONN YES disable ngx_http_upstream_least_conn_module
--without-http_upstream_random_module HTTP_UPSTREAM_RANDOM YES disable ngx_http_upstream_random_module
--without-http_upstream_zone_module HTTP_UPSTREAM_ZONE YES disable ngx_http_upstream_zone_module
--without-http_userid_module HTTP_USERID YES disable ngx_http_userid_module
--without-http_uwsgi_module HTTP_UWSGI YES disable ngx_http_uwsgi_module
--with-http_v2_module HTTP_V2 NO enable ngx_http_v2_module
--with-http_v3_module HTTP_V3 NO enable ngx_http_v3_module
--with-http_xslt_module HTTP_XSLT NO enable ngx_http_xslt_module
--with-http_xslt_module= dynamic HTTP_XSLT NO enable dynamic ngx_http_xslt_module
--with-mail MAIL NO enable POP3/IMAP4/SMTP proxy module
--with-mail= dynamic MAIL NO enable dynamic POP3/IMAP4/SMTP proxy module
--with-imap MAIL Deprecated in favor of --with-mail
--without-mail_imap_module MAIL_IMAP YES disable ngx_mail_imap_module
--without-mail_pop3_module MAIL_POP3 YES disable ngx_mail_pop3_module
--without-mail_smtp_module MAIL_SMTP YES disable ngx_mail_smtp_module
--with-mail_ssl_module MAIL_SSL NO enable ngx_mail_ssl_module
--with-imap_ssl_module MAIL_SSL Deprecated in favor of --with-mail_ssl_module
--add-module= PATH NGX_ADDONS enable external module
NGX_ADDON_DEPS
NGX_ADDON_SRCS
--build= NAME NGX_BUILD set build name
--with-cc-opt= OPTIONS NGX_CC_OPT set additional C compiler options
--with-compat NGX_COMPAT NO dynamic modules compatibility
--conf-path= PATH NGX_CONF_PATH conf/nginx.conf set nginx.conf pathname
NGX_CONF_PREFIX
--with-cpp_test_module NGX_CPP_TEST NO enable ngx_cpp_test_module
NGX_CPU_CACHE_LINE
--with-debug NGX_DEBUG NO enable debug logging
--error-log-path= PATH NGX_ERROR_LOG_PATH set error log pathname
--with-file-aio NGX_FILE_AIO NO enable file AIO support
--with-google_perftools_module NGX_GOOGLE_PERFTOOLS NO enable ngx_google_perftools_module
--group= GROUP NGX_GROUP set non-privileged group for worker processes
--http-client-body-temp-path= PATH NGX_HTTP_CLIENT_TEMP_PATH set path to store http client request body temporary files
--http-fastcgi-temp-path= PATH NGX_HTTP_FASTCGI_TEMP_PATH set path to store http fastcgi temporary files
--http-log-path= PATH NGX_HTTP_LOG_PATH set http access log pathname
--http-proxy-temp-path= PATH NGX_HTTP_PROXY_TEMP_PATH set path to store http proxy temporary files
--http-scgi-temp-path= PATH NGX_HTTP_SCGI_TEMP_PATH set path to store http scgi temporary files
--http-uwsgi-temp-path= PATH NGX_HTTP_UWSGI_TEMP_PATH set path to store http uwsgi temporary files
--with-ld-opt= OPTIONS NGX_LD_OPT set additional linker options
--with-libatomic NGX_LIBATOMIC NO force libatomic_ops library usage
--with-libatomic= DIR NGX_LIBATOMIC NO set path to libatomic_ops library sources
--lock-path= PATH NGX_LOCK_PATH set nginx.lock pathname
--modules-path= PATH NGX_MODULES_PATH set modules path
--builddir= DIR NGX_OBJS objs set build directory
--with-perl= PATH NGX_PERL perl set perl binary pathname
--with-perl_modules_path= PATH NGX_PERL_MODULES set Perl modules path
--pid-path= PATH NGX_PID_PATH set nginx.pid pathname
--crossbuild= NGX_PLATFORM
NGX_POST_CONF_MSG
--prefix= PATH NGX_PREFIX /usr/local/nginx/ set installation prefix
NGX_RPATH NO
--sbin-path= PATH NGX_SBIN_PATH set nginx binary pathname
--test-build-devpoll NGX_TEST_BUILD_DEVPOLL
--test-build-epoll NGX_TEST_BUILD_EPOLL
--test-build-eventport NGX_TEST_BUILD_EVENTPORT
--test-build-solaris-sendfilev NGX_TEST_BUILD_SOLARIS_SENDFILEV
--user= USER NGX_USER set non-privileged user for worker processes
NGX_WINE
--with-openssl= DIR OPENSSL NONE set path to OpenSSL library sources
--with-openssl-opt= OPTIONS OPENSSL_OPT set additional build options for OpenSSL
--with-pcre= DIR PCRE NONE set path to PCRE library sources
--without-pcre2 PCRE2 YES do not use PCRE2 library
PCRE_CONF_OPT
--with-pcre-jit PCRE_JIT NO build PCRE with JIT compilation support
--with-pcre-opt= OPTIONS PCRE_OPT set additional build options for PCRE
--without-quic_bpf_module QUIC_BPF NO disable ngx_quic_bpf_module
SO_COOKIE_FOUND NO
--with-stream STREAM NO enable TCP/UDP proxy module
--with-stream= dynamic STREAM NO enable dynamic TCP/UDP proxy module
--without-stream_access_module STREAM_ACCESS YES disable ngx_stream_access_module
--without-stream_geo_module STREAM_GEO YES disable ngx_stream_geo_module
--with-stream_geoip_module STREAM_GEOIP NO enable ngx_stream_geoip_module
--with-stream_geoip_module= dynamic STREAM_GEOIP NO enable dynamic ngx_stream_geoip_module
--without-stream_limit_conn_module STREAM_LIMIT_CONN YES disable ngx_stream_limit_conn_module
--without-stream_map_module STREAM_MAP YES disable ngx_stream_map_module
--without-stream_pass_module STREAM_PASS YES disable ngx_stream_pass_module
--with-stream_realip_module STREAM_REALIP NO enable ngx_stream_realip_module
--without-stream_return_module STREAM_RETURN YES disable ngx_stream_return_module
--without-stream_set_module STREAM_SET YES disable ngx_stream_set_module
--without-stream_split_clients_module STREAM_SPLIT_CLIENTS YES disable ngx_stream_split_clients_module
--with-stream_ssl_module STREAM_SSL NO enable ngx_stream_ssl_module
--with-stream_ssl_preread_module STREAM_SSL_PREREAD NO enable ngx_stream_ssl_preread_module
--without-stream_upstream_hash_module STREAM_UPSTREAM_HASH YES disable ngx_stream_upstream_hash_module
--without-stream_upstream_least_conn_module STREAM_UPSTREAM_LEAST_CONN YES disable ngx_stream_upstream_least_conn_module
--without-stream_upstream_random_module STREAM_UPSTREAM_RANDOM YES disable ngx_stream_upstream_random_module
--without-stream_upstream_zone_module STREAM_UPSTREAM_ZONE YES disable ngx_stream_upstream_zone_module
USE_GEOIP NO
USE_LIBGD NO
USE_LIBXSLT NO
USE_OPENSSL NO
USE_OPENSSL_QUIC NO
--with-pcre USE_PCRE NO force PCRE library usage
--without-pcre USE_PCRE NO disable PCRE library usage
USE_PERL NO
--with-threads USE_THREADS NO enable thread pool support
USE_ZLIB NO
--with-zlib= DIR ZLIB NONE set path to zlib library sources
--with-zlib-asm= CPU ZLIB_ASM NO use zlib assembler sources optimized for the specified CPU, valid values: pentium, pentiumpro
--with-zlib-opt= OPTIONS ZLIB_OPT set additional build options for zlib
--help help print this message
--with-ipv6 Deprecated
--with-md5= Deprecated
--with-md5-opt= Deprecated
--with-md5-asm Deprecated
--with-sha1= Deprecated
--with-sha1-opt= Deprecated
--with-sha1-asm Deprecated

core/nginx.h

core/nginx.h #defines the following macros
name possible value
nginx_version 1027000
NGINX_VERSION 1.27.0
NGINX_VER_BUILD NGINX_VER or NGINX_VER " (" NGX_BUILD ")"`
NGX_OLDPID_EXT ".oldbin"

Querying the configure options

The configure options with which nginx was built can be quried like so:
sudo /usr/sbin/nginx -V 2>&1  | grep '^configure arguments' | sed 's/ --/\n--/g'
On my current Debian system, this command returned:
configure arguments:
--with-cc-opt='-g -O2 -ffile-prefix-map=/build/nginx-AoTv4W/nginx-1.22.1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2'
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -fPIC'
--prefix=/usr/share/nginx
--conf-path=/etc/nginx/nginx.conf
--http-log-path=/var/log/nginx/access.log
--error-log-path=stderr
--lock-path=/var/lock/nginx.lock
--pid-path=/run/nginx.pid
--modules-path=/usr/lib/nginx/modules
--http-client-body-temp-path=/var/lib/nginx/body
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi
--http-proxy-temp-path=/var/lib/nginx/proxy
--http-scgi-temp-path=/var/lib/nginx/scgi
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi
--with-compat
--with-debug
--with-pcre-jit
--with-http_ssl_module
--with-http_stub_status_module
--with-http_realip_module
--with-http_auth_request_module
--with-http_v2_module
--with-http_dav_module
--with-http_slice_module
--with-threads
--with-http_addition_module
--with-http_flv_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_mp4_module
--with-http_random_index_module
--with-http_secure_link_module
--with-http_sub_module
--with-mail_ssl_module
--with-stream_ssl_module
--with-stream_ssl_preread_module
--with-stream_realip_module
--with-http_geoip_module=dynamic
--with-http_image_filter_module=dynamic
--with-http_perl_module=dynamic
--with-http_xslt_module=dynamic
--with-mail=dynamic
--with-stream=dynamic
--with-stream_geoip_module=dynamic

TODO

APT package python3-certbot-nginx

$ apt show python3-certbot-nginx 2>/dev/null | grep Description
Description: Nginx plugin for Certbot

Configure options

What is the benefit of using the auto/configure option --with-threads. See also the configure-time file auto/threads.
What is the purpose of using --without-http?

Dynamic modules

Configuring:
./configure --with-http_image_filter_module=dynamic
./configure --add-dynamic-module=/path/to/module
nginx.conf
load_module modules/ngx_http_image_filter_module.so;

See also

/etc/nginx is the directory in which nginx is configured.
Configuring nginx as an application gateway for a WSGI server
web server
nginx supports QUIC since version 1.25.0.

Links

Getting started

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/web/webs...', 1758199429, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/web/webserver/nginx/index(1310): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78