]> git.kaiwu.me - nginx.git/log
nginx.git
13 years agoRequest body: only read body in main request (ticket #330).
Maxim Dounin [Tue, 16 Apr 2013 10:14:59 +0000 (10:14 +0000)]
Request body: only read body in main request (ticket #330).

Before 1.3.9 an attempt to read body in a subrequest only caused problems
if body wasn't already read or discarded in a main request.  Starting with
1.3.9 it might also cause problems if body was discarded by a main request
before subrequest start.

Fix is to just ignore attempts to read request body in a subrequest, which
looks like right thing to do anyway.

13 years agoUpstream: warn if multiple non-stackable balancers are installed.
Ruslan Ermilov [Fri, 12 Apr 2013 19:12:13 +0000 (19:12 +0000)]
Upstream: warn if multiple non-stackable balancers are installed.

13 years agoEvents: fixed typos in two previous commits.
Valentin Bartenev [Fri, 12 Apr 2013 17:31:08 +0000 (17:31 +0000)]
Events: fixed typos in two previous commits.

13 years agoEvents: handle only active events in eventport.
Valentin Bartenev [Fri, 12 Apr 2013 15:04:23 +0000 (15:04 +0000)]
Events: handle only active events in eventport.

We generate both read and write events if an error event was returned by
port_getn() without POLLIN/POLLOUT, but we should not try to handle inactive
events, they may even have no handler.

13 years agoEvents: protection from stale events in eventport and devpoll.
Valentin Bartenev [Fri, 12 Apr 2013 15:02:33 +0000 (15:02 +0000)]
Events: protection from stale events in eventport and devpoll.

Stale write event may happen if read and write events was reported both,
and processing of the read event closed descriptor.

In practice this might result in "sendfilev() failed (134: ..." or
"writev() failed (134: ..." errors when switching to next upstream server.

See report here:
http://mailman.nginx.org/pipermail/nginx/2013-April/038421.html

13 years agoUpstream: fixed $upstream_response_length without buffering.
Sergey Kandaurov [Thu, 11 Apr 2013 13:49:13 +0000 (13:49 +0000)]
Upstream: fixed $upstream_response_length without buffering.

Reported by Piotr Sikora.

13 years agoConfigure: fixed nginx.so rebuild (broken by r5145).
Maxim Dounin [Wed, 10 Apr 2013 17:07:44 +0000 (17:07 +0000)]
Configure: fixed nginx.so rebuild (broken by r5145).

To avoid further breaks it's now done properly, all the dependencies
are now passed to Makefile.PL.  While here, fixed include list passed to
Makefile.PL to use Makefile variables rather than a list expanded during
configure.

13 years agoUpstream: removed surplus ngx_resolve_name_done() call.
Valentin Bartenev [Thu, 4 Apr 2013 14:19:06 +0000 (14:19 +0000)]
Upstream: removed surplus ngx_resolve_name_done() call.

It will be called in ngx_http_upstream_finalize_request().

13 years agoLimit req: rate should be non-zero.
Valentin Bartenev [Wed, 3 Apr 2013 14:13:35 +0000 (14:13 +0000)]
Limit req: rate should be non-zero.

Specifying zero rate caused division by zero when calculating delays.

13 years agoPass PCRE_CASELESS to pcre_compile() for caseless matching.
Ruslan Ermilov [Fri, 29 Mar 2013 08:47:37 +0000 (08:47 +0000)]
Pass PCRE_CASELESS to pcre_compile() for caseless matching.

Previously, we sometimes passed constant value 1 that happens to
match PCRE_CASELESS and thus was harmless.

13 years agoConfigure: unified nginx version computation constructs.
Ruslan Ermilov [Thu, 28 Mar 2013 08:47:25 +0000 (08:47 +0000)]
Configure: unified nginx version computation constructs.

13 years agoSimplified nginx version maintenance.
Ruslan Ermilov [Thu, 28 Mar 2013 08:47:06 +0000 (08:47 +0000)]
Simplified nginx version maintenance.

It's no longer necessary to update src/http/modules/perl/nginx.pm
when version is bumped, as it's now derived from src/core/nginx.h.

13 years agoConfigure: fixed perl module make rules.
Ruslan Ermilov [Thu, 28 Mar 2013 08:46:42 +0000 (08:46 +0000)]
Configure: fixed perl module make rules.

Filename extension used for dynamically loaded perl modules isn't
necessarily ".so" (e.g., it's ".bundle" on Mac OS X).

This fixes "make" after "make" unnecessarily rebuilding perl module.

13 years agoConfigure: improved make dependencies for perl module.
Ruslan Ermilov [Thu, 28 Mar 2013 08:46:12 +0000 (08:46 +0000)]
Configure: improved make dependencies for perl module.

Added missing dependencies for perl module's Makefile.

Simplified dependencies for perl module nginx.so: it depends
on Makefile that in turn depends on other perl bits.

13 years agoConfigure: improved layout of the generated makefile.
Ruslan Ermilov [Thu, 28 Mar 2013 08:45:45 +0000 (08:45 +0000)]
Configure: improved layout of the generated makefile.

No functional changes.

13 years agoUpstream: fixed tcp_nodelay with connection upgrade (ticket #325).
Maxim Dounin [Wed, 27 Mar 2013 15:18:34 +0000 (15:18 +0000)]
Upstream: fixed tcp_nodelay with connection upgrade (ticket #325).

13 years agoEvent connect: don't penalize AF_INET6 connections.
Maxim Dounin [Wed, 27 Mar 2013 15:16:45 +0000 (15:16 +0000)]
Event connect: don't penalize AF_INET6 connections.

Problems with setsockopt(TCP_NODELAY) and setsockopt(TCP_NOPUSH), as well
as sendfile() syscall on Solaris, are specific to UNIX-domain sockets.
Other address families, i.e. AF_INET and AF_INET6, are fine.

13 years agoVersion bump.
Maxim Dounin [Wed, 27 Mar 2013 15:15:34 +0000 (15:15 +0000)]
Version bump.

13 years agorelease-1.3.15 tag
Maxim Dounin [Tue, 26 Mar 2013 13:03:14 +0000 (13:03 +0000)]
release-1.3.15 tag

13 years agonginx-1.3.15-RELEASE release-1.3.15
Maxim Dounin [Tue, 26 Mar 2013 13:03:02 +0000 (13:03 +0000)]
nginx-1.3.15-RELEASE

13 years agoUse NGX_FILE_ERROR for handling file operations errors.
Valentin Bartenev [Mon, 25 Mar 2013 15:49:11 +0000 (15:49 +0000)]
Use NGX_FILE_ERROR for handling file operations errors.

On Win32 platforms 0 is used to indicate errors in file operations, so
comparing against -1 is not portable.

This was not much of an issue in patched code, since only ngx_fd_info() test
is actually reachable on Win32 and in worst case it might result in bogus
error log entry.

Patch by Piotr Sikora.

13 years agoUpstream: removed rudiments of upstream connection caching.
Ruslan Ermilov [Mon, 25 Mar 2013 14:51:44 +0000 (14:51 +0000)]
Upstream: removed rudiments of upstream connection caching.

This functionality is now provided by ngx_http_upstream_keepalive_module.

13 years agoUpstream: removed sorting of upstream servers.
Ruslan Ermilov [Mon, 25 Mar 2013 13:41:30 +0000 (13:41 +0000)]
Upstream: removed sorting of upstream servers.

Sorting of upstream servers by their weights is not required by
current balancing algorithms.

This will likely change mapping to backends served by ip_hash
weighted upstreams.

13 years agoMail: IPv6 backends (ticket #323).
Ruslan Ermilov [Mon, 25 Mar 2013 13:38:59 +0000 (13:38 +0000)]
Mail: IPv6 backends (ticket #323).

13 years agoUpstream: removed double-free workarounds in peer.free() methods.
Ruslan Ermilov [Mon, 25 Mar 2013 13:16:55 +0000 (13:16 +0000)]
Upstream: removed double-free workarounds in peer.free() methods.

13 years agoUpstream: only call peer.free() if peer.get() selected a peer.
Ruslan Ermilov [Mon, 25 Mar 2013 13:14:49 +0000 (13:14 +0000)]
Upstream: only call peer.free() if peer.get() selected a peer.

13 years agoMisc: support for Mercurial repositories.
Maxim Dounin [Fri, 22 Mar 2013 15:47:18 +0000 (15:47 +0000)]
Misc: support for Mercurial repositories.

13 years agoMisc: removed unused "snapshot" target.
Maxim Dounin [Fri, 22 Mar 2013 15:14:43 +0000 (15:14 +0000)]
Misc: removed unused "snapshot" target.

13 years agoMisc: switch to single export operation in "zip" target.
Maxim Dounin [Fri, 22 Mar 2013 15:14:07 +0000 (15:14 +0000)]
Misc: switch to single export operation in "zip" target.

While exporting parts of the tree might be better in some cases, it
is awfully slow overseas, and also requires unlocking ssh key multiple
times.  Exporting the whole repo and removing directories not needed for
zip is faster here.

It is also a required step before we can switch to Mercurial.

13 years agoSplit clients: check length when parsing configuration.
Ruslan Ermilov [Thu, 21 Mar 2013 16:06:53 +0000 (16:06 +0000)]
Split clients: check length when parsing configuration.

13 years agoRemoved unused ngx_http_clear_variable() macro.
Ruslan Ermilov [Thu, 21 Mar 2013 16:06:13 +0000 (16:06 +0000)]
Removed unused ngx_http_clear_variable() macro.

13 years agoFixed language in a comment preceding ngx_http_index_handler().
Ruslan Ermilov [Thu, 21 Mar 2013 16:05:35 +0000 (16:05 +0000)]
Fixed language in a comment preceding ngx_http_index_handler().

13 years agoMoved ngx_array_t definition from ngx_core.h to ngx_array.h.
Ruslan Ermilov [Thu, 21 Mar 2013 16:04:09 +0000 (16:04 +0000)]
Moved ngx_array_t definition from ngx_core.h to ngx_array.h.

13 years agoUse NGX_DEFAULT_POOL_SIZE macro where appropriate.
Ruslan Ermilov [Thu, 21 Mar 2013 16:03:24 +0000 (16:03 +0000)]
Use NGX_DEFAULT_POOL_SIZE macro where appropriate.

13 years agoSimplified ngx_array_create().
Ruslan Ermilov [Thu, 21 Mar 2013 15:52:52 +0000 (15:52 +0000)]
Simplified ngx_array_create().

13 years agoCore: fixed resource leak if binary upgrade fails due to no memory.
Ruslan Ermilov [Wed, 20 Mar 2013 18:07:25 +0000 (18:07 +0000)]
Core: fixed resource leak if binary upgrade fails due to no memory.

Found by Coverity (CID 992320).

13 years agoPreliminary experimental support for SPDY draft 2.
Valentin Bartenev [Wed, 20 Mar 2013 10:36:57 +0000 (10:36 +0000)]
Preliminary experimental support for SPDY draft 2.

13 years agoWin32: disabled MSVC warning about '\0' not fitting into array.
Valentin Bartenev [Wed, 20 Mar 2013 10:18:26 +0000 (10:18 +0000)]
Win32: disabled MSVC warning about '\0' not fitting into array.

We believe that this warning produces more inconvience than real benefit.
Here is an example to trigger:

  u_char a[4] = "test";

13 years agoURI processing code moved to a separate function.
Valentin Bartenev [Wed, 20 Mar 2013 09:36:27 +0000 (09:36 +0000)]
URI processing code moved to a separate function.

This allows to reuse it in the upcoming SPDY module.

13 years agoImage filter: the "image_filter_interlace" directive.
Ruslan Ermilov [Tue, 19 Mar 2013 08:13:48 +0000 (08:13 +0000)]
Image filter: the "image_filter_interlace" directive.

Patch by Ian Babrou, with minor changes.

13 years agoThe limit_req_status and limit_conn_status directives.
Maxim Dounin [Mon, 18 Mar 2013 14:50:29 +0000 (14:50 +0000)]
The limit_req_status and limit_conn_status directives.

Patch by Nick Marden, with minor changes.

13 years agoCore: guard against failed allocation during binary upgrade.
Ruslan Ermilov [Mon, 18 Mar 2013 07:13:57 +0000 (07:13 +0000)]
Core: guard against failed allocation during binary upgrade.

Patch by Piotr Sikora.

13 years agoStatus: introduced the "ngx_stat_waiting" counter.
Valentin Bartenev [Fri, 15 Mar 2013 20:00:49 +0000 (20:00 +0000)]
Status: introduced the "ngx_stat_waiting" counter.

And corresponding variable $connections_waiting was added.

Previously, waiting connections were counted as the difference between
active connections and the sum of reading and writing connections.
That made it impossible to count more than one request in one connection
as reading or writing (as is the case for SPDY).

Also, we no longer count connections in handshake state as waiting.

13 years agoAllow to reuse connections that wait their first request.
Valentin Bartenev [Fri, 15 Mar 2013 19:49:54 +0000 (19:49 +0000)]
Allow to reuse connections that wait their first request.

This should improve behavior under deficiency of connections.

Since SSL handshake usually takes significant amount of time,
we exclude connections from reusable queue during this period
to avoid premature flush of them.

13 years agoUpstream: fixed previous commit.
Maxim Dounin [Thu, 14 Mar 2013 16:22:43 +0000 (16:22 +0000)]
Upstream: fixed previous commit.

Store r->connection on stack to make sure it's still available if request
finalization happens to actually free request memory.

13 years agoUpstream: call ngx_http_run_posted_requests() on resolve errors.
Maxim Dounin [Thu, 14 Mar 2013 12:37:54 +0000 (12:37 +0000)]
Upstream: call ngx_http_run_posted_requests() on resolve errors.

If proxy_pass to a host with dynamic resolution was used to handle
a subrequest, and host resolution failed, the main request wasn't run
till something else happened on the connection.  E.g. request to "/zzz"
with the following configuration hanged:

    addition_types *;
    resolver 8.8.8.8;

    location /test {
        set $ihost xxx;
        proxy_pass http://$ihost;
    }

    location /zzz {
      add_after_body /test;
      return 200 "test";
    }

Report and original version of the patch by Lanshun Zhou,
http://mailman.nginx.org/pipermail/nginx-devel/2013-March/003476.html.

13 years agoRequest body: avoid linking rb->buf to r->header_in.
Maxim Dounin [Thu, 14 Mar 2013 12:30:26 +0000 (12:30 +0000)]
Request body: avoid linking rb->buf to r->header_in.

Code to reuse of r->request_body->buf in upstream module assumes it's
dedicated buffer, hence after 1.3.9 (r4931) it might reuse r->header_in
if client_body_in_file_only was set, resulting in original request
corruption.  It is considered to be safer to always create a dedicated
buffer for rb->bufs to avoid such problems.

13 years agoRequest body: next upstream fix.
Maxim Dounin [Thu, 14 Mar 2013 12:28:53 +0000 (12:28 +0000)]
Request body: next upstream fix.

After introduction of chunked request body handling in 1.3.9 (r4931),
r->request_body->bufs buffers have b->start pointing to original buffer
start (and b->pos pointing to real data of this particular buffer).

While this is ok as per se, it caused bad things (usually original request
headers included before the request body) after reinit of the request
chain in ngx_http_upstream_reinit() while sending the request to a next
upstream server (which used to do b->pos = b->start for each buffer
in the request chain).

Patch by Piotr Sikora.

13 years agoFixed logging in ngx_http_wait_request_handler().
Maxim Dounin [Tue, 12 Mar 2013 13:38:04 +0000 (13:38 +0000)]
Fixed logging in ngx_http_wait_request_handler().

If c->recv() returns 0 there is no sense in using ngx_socket_errno for
logging, its value meaningless.  (The code in question was copied from
ngx_http_keepalive_handler(), but ngx_socket_errno makes sense there as it's
used as a part of ECONNRESET handling, and the c->recv() call is preceeded
by the ngx_set_socket_errno(0) call.)

13 years agoRemoved unused prototype of ngx_http_find_server_conf().
Valentin Bartenev [Mon, 11 Mar 2013 14:44:56 +0000 (14:44 +0000)]
Removed unused prototype of ngx_http_find_server_conf().

This function prototype and its implementation was added in r90,
but the implementation was removed in r97.

13 years agoGzip: fixed setting of NGX_HTTP_GZIP_BUFFERED.
Valentin Bartenev [Mon, 11 Mar 2013 11:19:58 +0000 (11:19 +0000)]
Gzip: fixed setting of NGX_HTTP_GZIP_BUFFERED.

In r2411 setting of NGX_HTTP_GZIP_BUFFERED in c->buffered was moved from
ngx_http_gzip_filter_deflate_start() to ngx_http_gzip_filter_buffer() since
it was always called first.  But in r2543 the "postpone_gzipping" directive
was introduced, and if postponed gzipping is disabled (the default setting),
ngx_http_gzip_filter_buffer() is not called at all.

We must always set NGX_HTTP_GZIP_BUFFERED after the start of compression
since there is always a trailer that is buffered.

There are no known cases when it leads to any problem with current code.
But we already had troubles in upcoming SPDY implementation.

13 years agoSSL: Next Protocol Negotiation extension support.
Valentin Bartenev [Thu, 7 Mar 2013 18:21:28 +0000 (18:21 +0000)]
SSL: Next Protocol Negotiation extension support.

Not only this is useful for the upcoming SPDY support, but it can
also help to improve HTTPS performance by enabling TLS False Start
in Chrome/Chromium browsers [1].  So, we always enable NPN for HTTPS
if it is supported by OpenSSL.

[1] http://www.imperialviolet.org/2012/04/11/falsestart.html

13 years agoRefactored ngx_http_init_request().
Valentin Bartenev [Thu, 7 Mar 2013 18:14:27 +0000 (18:14 +0000)]
Refactored ngx_http_init_request().

Now it can be used as the request object factory with minimal impact on the
connection object.  Therefore it was renamed to ngx_http_create_request().

13 years agoRemoved c->single_connection flag.
Valentin Bartenev [Thu, 7 Mar 2013 18:07:16 +0000 (18:07 +0000)]
Removed c->single_connection flag.

The c->single_connection was intended to be used as lock mechanism
to serialize modifications of request object from several threads
working with client and upstream connections.  The flag is redundant
since threads in nginx have never been used that way.

13 years agoRespect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev [Thu, 7 Mar 2013 17:59:27 +0000 (17:59 +0000)]
Respect the new behavior of TCP_DEFER_ACCEPT.

In Linux 2.6.32, TCP_DEFER_ACCEPT was changed to accept connections
after the deferring period is finished without any data available.
(Reading from the socket returns EAGAIN in this case.)

Since in nginx TCP_DEFER_ACCEPT is set to "post_accept_timeout", we
do not need to wait longer if deferred accept returns with no data.

13 years agoUse "client_header_timeout" for all requests in a connection.
Valentin Bartenev [Thu, 7 Mar 2013 17:41:40 +0000 (17:41 +0000)]
Use "client_header_timeout" for all requests in a connection.

Previously, only the first request in a connection used timeout
value from the "client_header_timeout" directive while reading
header.  All subsequent requests used "keepalive_timeout" for
that.

It happened because timeout of the read event was set to the
value of "keepalive_timeout" in ngx_http_set_keepalive(), but
was not removed when the next request arrived.

13 years agoCreate request object only after the first byte was received.
Valentin Bartenev [Thu, 7 Mar 2013 17:21:50 +0000 (17:21 +0000)]
Create request object only after the first byte was received.

Previously, we always created an object and logged 400 (Bad Request)
in access log if a client closed connection without sending any data.
Such a connection was counted as "reading".

Since it's common for modern browsers to behave like this, it's no
longer considered an error if a client closes connection without
sending any data, and such a connection will be counted as "waiting".

Now, we do not log 400 (Bad Request) and keep memory footprint as
small as possible.

13 years agoVersion bump.
Valentin Bartenev [Thu, 7 Mar 2013 17:07:04 +0000 (17:07 +0000)]
Version bump.

13 years agorelease-1.3.14 tag
Maxim Dounin [Tue, 5 Mar 2013 14:36:20 +0000 (14:36 +0000)]
release-1.3.14 tag

13 years agonginx-1.3.14-RELEASE release-1.3.14
Maxim Dounin [Tue, 5 Mar 2013 14:35:58 +0000 (14:35 +0000)]
nginx-1.3.14-RELEASE

13 years agoMp4: fixed handling of too small mdat atoms (ticket #266).
Maxim Dounin [Mon, 4 Mar 2013 15:39:03 +0000 (15:39 +0000)]
Mp4: fixed handling of too small mdat atoms (ticket #266).

Patch by Gernot Vormayr (with minor changes).

13 years agoAllocate request object from its own pool.
Valentin Bartenev [Fri, 1 Mar 2013 14:55:42 +0000 (14:55 +0000)]
Allocate request object from its own pool.

Previously, it was allocated from a connection pool and
was selectively freed for an idle keepalive connection.

The goal is to put coupled things in one chunk of memory,
and to simplify handling of request objects.

13 years agoSNI: added restriction on requesting host other than negotiated.
Valentin Bartenev [Wed, 27 Feb 2013 17:41:34 +0000 (17:41 +0000)]
SNI: added restriction on requesting host other than negotiated.

According to RFC 6066, client is not supposed to request a different server
name at the application layer.  Server implementations that rely upon these
names being equal must validate that a client did not send a different name
in HTTP request.  Current versions of Apache HTTP server always return 400
"Bad Request" in such cases.

There exist implementations however (e.g., SPDY) that rely on being able to
request different host names in one connection.  Given this, we only reject
requests with differing host names if verification of client certificates
is enabled in a corresponding server configuration.

An example of configuration that might not work as expected:

  server {
      listen 433 ssl default;
      return 404;
  }

  server {
      listen 433 ssl;
      server_name example.org;

      ssl_client_certificate org.cert;
      ssl_verify_client on;
  }

  server {
      listen 433 ssl;
      server_name example.com;

      ssl_client_certificate com.cert;
      ssl_verify_client on;
  }

Previously, a client was able to request example.com by presenting
a certificate for example.org, and vice versa.

13 years agoSNI: reset to default server if requested host was not found.
Valentin Bartenev [Wed, 27 Feb 2013 17:38:54 +0000 (17:38 +0000)]
SNI: reset to default server if requested host was not found.

Not only this is consistent with a case without SNI, but this also
prevents abusing configurations that assume that the $host variable
is limited to one of the configured names for a server.

An example of potentially unsafe configuration:

  server {
      listen 443 ssl default_server;
      ...
  }

  server {
      listen 443;
      server_name example.com;

      location / {
          proxy_pass http://$host;
      }
  }

Note: it is possible to negotiate "example.com" by SNI, and to request
arbitrary host name that does not exist in the configuration above.

13 years agoSNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev [Wed, 27 Feb 2013 17:33:59 +0000 (17:33 +0000)]
SNI: avoid surplus lookup of virtual server if SNI was used.

13 years agoApply server configuration as soon as host is known.
Valentin Bartenev [Wed, 27 Feb 2013 17:27:15 +0000 (17:27 +0000)]
Apply server configuration as soon as host is known.

Previously, this was done only after the whole request header
was parsed, and if an error occurred earlier then the request
was processed in the default server (or server chosen by SNI),
while r->headers_in.server might be set to the value from the
Host: header or host from request line.

r->headers_in.server is in turn used for $host variable and
in HTTP redirects if "server_name_in_redirect" is disabled.
Without the change, configurations that rely on this during
error handling are potentially unsafe if SNI is used.

This change also allows to use server specific settings of
"underscores_in_headers", "ignore_invalid_headers", and
"large_client_header_buffers" directives for HTTP requests
and HTTPS requests without SNI.

13 years agoSSL: do not treat SSL handshake as request.
Valentin Bartenev [Wed, 27 Feb 2013 17:21:21 +0000 (17:21 +0000)]
SSL: do not treat SSL handshake as request.

The request object will not be created until SSL handshake is complete.
This simplifies adding another connection handler that does not need
request object right after handshake (e.g., SPDY).

There are also a few more intentional effects:

 - the "client_header_buffer_size" directive will be taken from the
   server configuration that was negotiated by SNI;

 - SSL handshake errors and timeouts are not logged into access log
   as bad requests;

 - ngx_ssl_create_connection() is not called until the first byte of
   ClientHello message was received.  This also decreases memory
   consumption if plain HTTP request is sent to SSL socket.

13 years agoStatus: do not count connection as reading right after accept().
Valentin Bartenev [Wed, 27 Feb 2013 17:16:51 +0000 (17:16 +0000)]
Status: do not count connection as reading right after accept().

Before we receive the first bytes, the connection is counted
as waiting.

This change simplifies further code changes.

13 years agoSNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev [Wed, 27 Feb 2013 17:12:48 +0000 (17:12 +0000)]
SNI: reuse selected configuration for all requests in a connection.

Previously, only the first request in a connection was assigned the
configuration selected by SNI.  All subsequent requests initially
used the default server's configuration, ignoring SNI, which was
wrong.

Now all subsequent requests in a connection will initially use the
configuration selected by SNI.  This is done by storing a pointer
to configuration in http connection object.  It points to default
server's configuration initially, but changed upon receipt of SNI.

(The request's configuration can be further refined when parsing
the request line and Host: header.)

This change was not made specific to SNI as it also allows slightly
faster access to configuration without the request object.

13 years agoSNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev [Wed, 27 Feb 2013 17:06:52 +0000 (17:06 +0000)]
SNI: ignore captures in server_name regexes when matching by SNI.

This change helps to decouple ngx_http_ssl_servername() from the request
object.

Note: now we close connection in case of error during server name lookup
for request.  Previously, we did so only for HTTP/0.9 requests.

13 years agoChanged interface of ngx_http_validate_host().
Valentin Bartenev [Wed, 27 Feb 2013 17:03:14 +0000 (17:03 +0000)]
Changed interface of ngx_http_validate_host().

13 years agoIntroduced the ngx_http_set_connection_log() macro.
Valentin Bartenev [Wed, 27 Feb 2013 16:56:47 +0000 (16:56 +0000)]
Introduced the ngx_http_set_connection_log() macro.

No functional changes.

13 years agoThe default server lookup is now done only once per connection.
Valentin Bartenev [Wed, 27 Feb 2013 16:53:01 +0000 (16:53 +0000)]
The default server lookup is now done only once per connection.

Previously, it was done for every request in a connection.

13 years agoCorrectly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov [Wed, 27 Feb 2013 13:29:50 +0000 (13:29 +0000)]
Correctly handle multiple X-Forwarded-For headers (ticket #106).

13 years agoFixed separator in $sent_http_cache_control.
Ruslan Ermilov [Wed, 27 Feb 2013 13:22:20 +0000 (13:22 +0000)]
Fixed separator in $sent_http_cache_control.

In case multiple "Cache-Control" headers are sent to a client,
multiple values in $sent_http_cache_control were incorrectly
split by a semicolon.  Now they are split by a comma.

13 years agoFixed potential segfault in ngx_http_keepalive_handler().
Valentin Bartenev [Sat, 23 Feb 2013 13:23:48 +0000 (13:23 +0000)]
Fixed potential segfault in ngx_http_keepalive_handler().

In case of error in the read event handling we close a connection
by calling ngx_http_close_connection(), that also destroys connection
pool. Thereafter, an attempt to free a buffer (added in r4892) that
was allocated from the pool could cause SIGSEGV and is meaningless
as well (the buffer already freed with the pool).

13 years agoSSL: retry "sess_id" and "id" allocations.
Maxim Dounin [Sat, 23 Feb 2013 11:54:25 +0000 (11:54 +0000)]
SSL: retry "sess_id" and "id" allocations.

In case of fully populated SSL session cache with no memory left for
new allocations, ngx_ssl_new_session() will try to expire the oldest
non-expired session and retry, but only in case when slab allocation
fails for "cached_sess", not when slab allocation fails for either
"sess_id" or "id", which can happen for number of reasons and results
in new session not being cached.

Patch fixes this by adding retry logic to "sess_id" & "id" allocations.

Patch by Piotr Sikora.

13 years agoTrailing whitespace fix.
Maxim Dounin [Sat, 23 Feb 2013 11:50:42 +0000 (11:50 +0000)]
Trailing whitespace fix.

13 years agoIntroduced variables in ngx_http_stub_status module.
Andrey Belov [Thu, 21 Feb 2013 23:31:57 +0000 (23:31 +0000)]
Introduced variables in ngx_http_stub_status module.

Three new variables were added: $connections_active, $connections_reading
and $connections_writing.

13 years agoConnection upgrade support in uwsgi and scgi modules.
Maxim Dounin [Wed, 20 Feb 2013 16:41:05 +0000 (16:41 +0000)]
Connection upgrade support in uwsgi and scgi modules.

Prodded by Roberto De Ioris.

13 years agoRemoved zero termination of shm zone names.
Valentin Bartenev [Tue, 19 Feb 2013 17:48:45 +0000 (17:48 +0000)]
Removed zero termination of shm zone names.

It was added in r2717 and no longer needed since r2721,
where the termination was added to ngx_shm_alloc() and
ngx_init_zone_pool().  So then it only corrupts error
messages about ivalid zones.

13 years agoVersion bump.
Valentin Bartenev [Tue, 19 Feb 2013 17:45:12 +0000 (17:45 +0000)]
Version bump.

13 years agorelease-1.3.13 tag
Maxim Dounin [Tue, 19 Feb 2013 15:15:11 +0000 (15:15 +0000)]
release-1.3.13 tag

13 years agonginx-1.3.13-RELEASE release-1.3.13
Maxim Dounin [Tue, 19 Feb 2013 15:14:48 +0000 (15:14 +0000)]
nginx-1.3.13-RELEASE

13 years agoProxy: fixed do_write handling in previous commit.
Maxim Dounin [Mon, 18 Feb 2013 15:08:46 +0000 (15:08 +0000)]
Proxy: fixed do_write handling in previous commit.

As rightfully complained by MSVC, do_write variable was used uninitialized.
Correct fix is to set it's initial value based on event happened.

13 years agoProxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin [Mon, 18 Feb 2013 13:50:52 +0000 (13:50 +0000)]
Proxy: support for connection upgrade (101 Switching Protocols).

This allows to proxy WebSockets by using configuration like this:

    location /chat/ {
        proxy_pass http://backend;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

Connection upgrade is allowed as long as it was requested by a client
via the Upgrade request header.

13 years agoConfigure: changed default compiler from "gcc" to "cc".
Gleb Smirnoff [Mon, 18 Feb 2013 11:35:28 +0000 (11:35 +0000)]
Configure: changed default compiler from "gcc" to "cc".

This allows to automatically pick the preferred system compiler on
systems with multiple compilers.

Reviewed by: mdounin, ru

13 years agoConfigure: rebuild perl module nginx.so if headers are changed.
Maxim Dounin [Fri, 15 Feb 2013 16:50:22 +0000 (16:50 +0000)]
Configure: rebuild perl module nginx.so if headers are changed.

Note: the "-p" argument of cp(1) dropped intentionally, to force nginx.so
rebuild.  It is considered too boring to properly list all dependencies
in Makefile.PL.

13 years agoFixed false memset warning on Linux with -O3 (ticket #275).
Maxim Dounin [Wed, 13 Feb 2013 14:39:46 +0000 (14:39 +0000)]
Fixed false memset warning on Linux with -O3 (ticket #275).

Prodded by John Leach.

13 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Mon, 11 Feb 2013 23:37:20 +0000 (23:37 +0000)]
Updated OpenSSL used for win32 builds.

13 years agoAdded support for {SHA} passwords (ticket #50).
Maxim Dounin [Thu, 7 Feb 2013 12:09:56 +0000 (12:09 +0000)]
Added support for {SHA} passwords (ticket #50).

Note: use of {SHA} passwords is discouraged as {SHA} password scheme is
vulnerable to attacks using rainbow tables.  Use of {SSHA}, $apr1$ or
crypt() algorithms as supported by OS is recommended instead.

The {SHA} password scheme support is added to avoid the need of changing
the scheme recorded in password files from {SHA} to {SSHA} because such
a change hides security problem with {SHA} passwords.

Patch by Louis Opter, with minor changes.

13 years agoVersion bump.
Maxim Dounin [Thu, 7 Feb 2013 12:09:09 +0000 (12:09 +0000)]
Version bump.

13 years agorelease-1.3.12 tag
Maxim Dounin [Tue, 5 Feb 2013 14:07:01 +0000 (14:07 +0000)]
release-1.3.12 tag

13 years agonginx-1.3.12-RELEASE release-1.3.12
Maxim Dounin [Tue, 5 Feb 2013 14:06:41 +0000 (14:06 +0000)]
nginx-1.3.12-RELEASE

13 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Tue, 5 Feb 2013 13:41:48 +0000 (13:41 +0000)]
Updated OpenSSL used for win32 builds.

13 years agoGeoIP: removed pseudo-support of "proxy" and "netspeed" databases.
Ruslan Ermilov [Mon, 4 Feb 2013 16:44:22 +0000 (16:44 +0000)]
GeoIP: removed pseudo-support of "proxy" and "netspeed" databases.

13 years agoFastCGI: proper handling of split fastcgi end request.
Maxim Dounin [Fri, 1 Feb 2013 14:41:50 +0000 (14:41 +0000)]
FastCGI: proper handling of split fastcgi end request.

If fastcgi end request record was split between several network packets,
with fastcgi_keep_conn it was possible that connection was saved in incorrect
state (e.g. with padding bytes not yet read).

13 years agoFastCGI: unconditional state transitions.
Maxim Dounin [Fri, 1 Feb 2013 14:41:07 +0000 (14:41 +0000)]
FastCGI: unconditional state transitions.

Checks for f->padding before state transitions make code hard to follow,
remove them and make sure we always do another loop iteration after
f->state is set to ngx_http_fastcgi_st_padding.

13 years agoFastCGI: fixed wrong connection close with fastcgi_keep_conn.
Maxim Dounin [Fri, 1 Feb 2013 14:40:19 +0000 (14:40 +0000)]
FastCGI: fixed wrong connection close with fastcgi_keep_conn.

With fastcgi_keep_conn it was possible that connection was closed after
FCGI_STDERR record with zero padding and without any further data read yet.
This happended as f->state was set to ngx_http_fastcgi_st_padding and then
"break" happened, resulting in p->length being set to f->padding, i.e. 0
(which in turn resulted in connection close).

Fix is to make sure we continue the loop after f->state is set.

13 years agoRequest body: fixed client_body_in_file_only.
Maxim Dounin [Fri, 1 Feb 2013 14:38:18 +0000 (14:38 +0000)]
Request body: fixed client_body_in_file_only.

After introduction of chunked request body reading support in 1.3.9 (r4931),
the rb->bufs wasn't set if request body was fully preread while calling the
ngx_http_read_client_request_body() function.

Reported by Yichun Zhang (agentzh).