nginx-1.3.13-RELEASE


git-svn-id: svn://svn.nginx.org/nginx/trunk@5075 73f98a42-aea0-e011-b76d-00259023448c
Version bump.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5077 73f98a42-aea0-e011-b76d-00259023448c
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().  Since then it only corrupted error
messages about invalid zones.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5078 73f98a42-aea0-e011-b76d-00259023448c
Connection upgrade support in uwsgi and scgi modules.

Prodded by Roberto De Ioris.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5079 73f98a42-aea0-e011-b76d-00259023448c
Introduced variables in ngx_http_stub_status module.

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


git-svn-id: svn://svn.nginx.org/nginx/trunk@5080 73f98a42-aea0-e011-b76d-00259023448c
Trailing whitespace fix.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5081 73f98a42-aea0-e011-b76d-00259023448c
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.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5082 73f98a42-aea0-e011-b76d-00259023448c
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).


git-svn-id: svn://svn.nginx.org/nginx/trunk@5083 73f98a42-aea0-e011-b76d-00259023448c
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.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5084 73f98a42-aea0-e011-b76d-00259023448c
Correctly handle multiple X-Forwarded-For headers (ticket #106).


git-svn-id: svn://svn.nginx.org/nginx/trunk@5085 73f98a42-aea0-e011-b76d-00259023448c
The default server lookup is now done only once per connection.

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


git-svn-id: svn://svn.nginx.org/nginx/trunk@5086 73f98a42-aea0-e011-b76d-00259023448c
Introduced the ngx_http_set_connection_log() macro.

No functional changes.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5087 73f98a42-aea0-e011-b76d-00259023448c
Changed interface of ngx_http_validate_host().


git-svn-id: svn://svn.nginx.org/nginx/trunk@5088 73f98a42-aea0-e011-b76d-00259023448c
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.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5089 73f98a42-aea0-e011-b76d-00259023448c
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.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5090 73f98a42-aea0-e011-b76d-00259023448c
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.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5091 73f98a42-aea0-e011-b76d-00259023448c
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.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5092 73f98a42-aea0-e011-b76d-00259023448c
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.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5093 73f98a42-aea0-e011-b76d-00259023448c
SNI: avoid surplus lookup of virtual server if SNI was used.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5094 73f98a42-aea0-e011-b76d-00259023448c
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.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5095 73f98a42-aea0-e011-b76d-00259023448c