view docs/man/nginx.8 @ 4247:b79dbadb3d5e stable-1.0

Merging r4147, r4148, r4149, r4150, r4207: Fixes of combination of error_page and return directives: *) Fix for incorrect 201 replies from dav module. Replies with 201 code contain body, and we should clearly indicate it's empty if it's empty. Before 0.8.32 chunked was explicitly disabled for 201 replies and as a result empty body was indicated by connection close (not perfect, but worked). Since 0.8.32 chunked is enabled, and this causes incorrect responses from dav module when HTTP/1.1 is used: with "Transfer-Encoding: chunked" but no chunks at all. Fix is to actually return empty body in special response handler instead of abusing r->header_only flag. See here for initial report: http://mailman.nginx.org/pipermail/nginx-ru/2010-October/037535.html *) Fix for double content when return is used in error_page handler. Test case: location / { error_page 405 /nope; return 405; } location /nope { return 200; } This is expected to return 405 with empty body, but in 0.8.42+ will return builtin 405 error page as well (though not counted in Content-Length, thus breaking protocol). Fix is to use status provided by rewrite script execution in case it's less than NGX_HTTP_BAD_REQUEST even if r->error_status set. This check is in line with one in ngx_http_script_return_code(). Note that this patch also changes behaviour for "return 302 ..." and "rewrite ... redirect" used as error handler. E.g. location / { error_page 405 /redirect; return 405; } location /redirect { rewrite ^ http://example.com/; } will actually return redirect to "http://example.com/" instead of builtin 405 error page with meaningless Location header. This looks like correct change and it's in line with what happens on e.g. directory redirects in error handlers. *) Fix for "return 202" not discarding body. Big POST (not fully preread) to a location / { return 202; } resulted in incorrect behaviour due to "return" code path not calling ngx_http_discard_request_body(). The same applies to all "return" used with 2xx/3xx codes except 201 and 204, and to all "return ... text" uses. Fix is to add ngx_http_discard_request_body() call to ngx_http_send_response() function where it looks appropriate. Discard body call from emtpy gif module removed as it's now redundant. Reported by Pyry Hakulinen, see http://mailman.nginx.org/pipermail/nginx/2011-August/028503.html *) Incorrect special case for "return 204" removed. The special case in question leads to replies without body in configuration like location / { error_page 404 /zero; return 404; } location /zero { return 204; } while replies with empty body are expected per protocol specs. Correct one will look like if (status == NGX_HTTP_NO_CONTENT) { rc = ngx_http_send_header(r); if (rc == NGX_ERROR || r->header_only) { return rc; } return ngx_http_send_special(r, NGX_HTTP_LAST); } though it looks like it's better to drop this special case at all. *) Clear old Location header (if any) while adding a new one. This prevents incorrect behaviour when another redirect is issued within error_page 302 handler.
author Igor Sysoev <igor@sysoev.ru>
date Tue, 01 Nov 2011 13:45:33 +0000
parents 8baa96142289
children 98f9fcd3c320 4d45c138e3df
line wrap: on
line source

.\"
.\" Copyright (c) 2010 Sergey A. Osokin
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"
.Dd November 14, 2010
.Dt NGINX 8
.Os
.Sh NAME
.Nm nginx
.Nd "HTTP and reverse proxy server, mail proxy server"
.Sh SYNOPSIS
.Nm
.Op Fl hqtvV?
.Op Fl c Ar file
.Op Fl g Ar directives
.Op Fl p Ar prefix
.Op Fl s Ar signal
.Sh DESCRIPTION
The
.Nm
(spelled
.Dq engine x )
is an HTTP and reverse proxy server, as well as a mail proxy server.
The
.Nm
is known for its high performance, stability, rich feature set, simple
configuration, and low resource consumption.
.Pp
The options are as follows:
.Bl -tag -width ".Fl d Ar directives"
.It Fl ?\& | h
Print help.
.It Fl c Ar file
Use an alternative configuration
.Ar file .
.It Fl g Ar directives
Set global configuration directives.
See
.Sx EXAMPLES
for details.
.It Fl p Ar prefix
Set prefix path.
Default value is
.Pa %%PREFIX%% .
.It Fl q
Suppress non-error messages during configuration testing.
.It Fl s Ar signal
Send signal to the master process.
The argument
.Ar signal
can be one of:
.Cm stop , quit , reopen , reload .
The following table shows the corresponding system signals.
.Pp
.Bl -tag -width ".It Cm reopen" -compact
.It Cm stop
.Dv SIGTERM
.It Cm quit
.Dv SIGQUIT
.It Cm reopen
.Dv SIGUSR1
.It Cm reload
.Dv SIGHUP
.El
.It Fl t
Don't run, just test the configuration file.
The
.Nm
checks configuration for correct syntax and then tries to open files
referred in configuration.
.It Fl v
Print
.Nm
version.
.It Fl V
Print
.Nm
version, compiler version and
.Pa configure
script parameters.
.El
.Sh SIGNALS
The master process of
.Nm
can handle the following signals.
.Pp
.Bl -tag -width ".It Dv SIGINT , SIGTERM" -compact
.It Dv SIGINT , SIGTERM
Shut down quickly.
.It Dv SIGHUP
Reload configuration, start the new worker process with a new
configuration, gracefully shut down old worker processes.
.It Dv SIGQUIT
Shut down gracefully.
.It Dv SIGUSR1
Reopen log files.
.It Dv SIGUSR2
Upgrade
.Nm
executable on the fly.
.It Dv SIGWINCH
Shut down gracefully worker processes.
.El
.Pp
While there's no need to explicitly control worker processes normally,
they support some signals, too:
.Pp
.Bl -tag -width ".It Dv SIGINT , SIGTERM" -compact
.It Dv SIGTERM
Shut down quickly.
.It Dv SIGQUIT
Shut down gracefully.
.It Dv SIGUSR1
Reopen log files.
.El
.Sh DEBUGGING LOG
To enable a debugging log, reconfigure
.Nm
to build with debugging:
.Pp
.Dl "./configure --with-debug ..."
.Pp
and then set the
.Cm debug
level of the
.Va error_log :
.Pp
.Dl "error_log /path/to/log debug;"
.Pp
It is also possible to enable the debugging for some IP address:
.Bd -literal -offset indent
events {
	debug_connection 127.0.0.1;
}
.Ed
.Sh FILES
.Bl -tag -width indent -compact
.It Pa %%PID_PATH%%
Contains the process ID of the
.Nm
listening for connections.
The content of this file is not sensitive; it can be world-readable.
.It Pa %%CONF_PATH%%
Main configuration file.
.It Pa %%ERROR_LOG_PATH%%
Error log file.
.El
.Sh EXIT STATUS
Exit status is 0 on success, or 1 if the command fails.
.Sh EXAMPLES
.Bd -literal
nginx -t -c ~/mynginx.conf -g "pid /var/run/mynginx.pid; worker_processes 2;"
.Ed
Test configuration file
.Pa ~/mynginx.conf
with global directives for PID and quantity of worker processes.
.Sh SEE ALSO
.Xr nginx.conf 5
.Sh HISTORY
Development of
.Nm
started in 2002, with the first public release on October 4, 2004.
.Sh AUTHORS
.An Igor Sysoev Aq igor@sysoev.ru
.Pp
Documentation available on
.Pa http://nginx.org/
and
.Pa http://sysoev.ru/nginx/ .
.Pp
This manual page was written by
.An Sergey A. Osokin Aq osa@FreeBSD.org.ru
as a result of compilation of many
.Nm
documents all over the world.
.Sh BUGS
Report to mailing list
.Aq Li nginx@nginx.org
if you found one.