]> git.kaiwu.me - nginx.git/log
nginx.git
13 years agoFixed sorting of listen addresses so that wildcard address is always at
Ruslan Ermilov [Tue, 17 Jul 2012 04:47:34 +0000 (04:47 +0000)]
Fixed sorting of listen addresses so that wildcard address is always at
the end (closes #187).  Failure to do so could result in several listen
sockets to be created instead of only one listening on wildcard address.

Reported by Roman Odaisky.

13 years agoVersion bump.
Ruslan Ermilov [Tue, 17 Jul 2012 04:42:38 +0000 (04:42 +0000)]
Version bump.

13 years agoSynchronized the license text with the FreeBSD's bsd-style-copyright.
Ruslan Ermilov [Tue, 10 Jul 2012 12:40:35 +0000 (12:40 +0000)]
Synchronized the license text with the FreeBSD's bsd-style-copyright.

13 years agorelease-1.3.3 tag
Maxim Dounin [Tue, 10 Jul 2012 12:20:30 +0000 (12:20 +0000)]
release-1.3.3 tag

13 years agonginx-1.3.3-RELEASE release-1.3.3
Maxim Dounin [Tue, 10 Jul 2012 12:20:10 +0000 (12:20 +0000)]
nginx-1.3.3-RELEASE

13 years agoEntity tags: empty etags handling in If-Range.
Maxim Dounin [Mon, 9 Jul 2012 17:04:37 +0000 (17:04 +0000)]
Entity tags: empty etags handling in If-Range.

Entity tag may be of length 2 as per RFC 2616, i.e. double quotes only.
Pointed out by Ruslan Ermilov.

13 years agoEntity tags: the "etag" directive.
Maxim Dounin [Mon, 9 Jul 2012 14:53:42 +0000 (14:53 +0000)]
Entity tags: the "etag" directive.

It allows to disable generation of nginx's own entity tags, while
still handling ETags in cache properly.  This may be useful e.g.
if one want to serve static files from servers with different ETag
generation algorithms.

13 years agoEntity tags: set for static respones.
Maxim Dounin [Mon, 9 Jul 2012 00:13:06 +0000 (00:13 +0000)]
Entity tags: set for static respones.

13 years agoEntity tags: handling in add_header.
Maxim Dounin [Sat, 7 Jul 2012 21:24:01 +0000 (21:24 +0000)]
Entity tags: handling in add_header.

Notably this allows to clear ETag if one want to for some reason.

13 years agoEntity tags: clear on entity changes.
Maxim Dounin [Sat, 7 Jul 2012 21:22:27 +0000 (21:22 +0000)]
Entity tags: clear on entity changes.

13 years agoEntity tags: support in If-Range header.
Maxim Dounin [Sat, 7 Jul 2012 21:21:15 +0000 (21:21 +0000)]
Entity tags: support in If-Range header.

13 years agoEntity tags: basic support in not modified filter.
Maxim Dounin [Sat, 7 Jul 2012 21:20:27 +0000 (21:20 +0000)]
Entity tags: basic support in not modified filter.

This includes handling of ETag headers (if present in a response) with
basic support for If-Match, If-None-Match conditionals in not modified
filter.

Note that the "r->headers_out.last_modified_time == -1" check in the not
modified filter is left as is intentionally.  It's to prevent handling
of If-* headers in case of proxy without cache (much like currently
done with If-Modified-Since).

13 years agoNot modified filter: tests separated from actions.
Maxim Dounin [Sat, 7 Jul 2012 21:18:30 +0000 (21:18 +0000)]
Not modified filter: tests separated from actions.

This makes code more extendable.  The only functional change is when
If-Modified-Since and If-Unmodified-Since are specified together, the
case which is explicitly left undefined by RFC 2616.  The new behaviour
is to respect them both, which seems better.

13 years agoAdded Last-Modified parsing in add_header.
Maxim Dounin [Sat, 7 Jul 2012 21:16:51 +0000 (21:16 +0000)]
Added Last-Modified parsing in add_header.

This allows to use last modified time set in If-Range checks.  Code
simplified to improve readability.

13 years agoFixed If-Range with unknown last modified time.
Maxim Dounin [Sat, 7 Jul 2012 21:16:21 +0000 (21:16 +0000)]
Fixed If-Range with unknown last modified time.

If modification time isn't known, skip range processing and return full
entity body instead of just ignoring If-Range.  Ignoring If-Range isn't
safe as client will assume entity wasn't changed since time specified.

13 years agoConfigure: fixed "make" used instead of "${MAKE}".
Maxim Dounin [Sat, 7 Jul 2012 09:35:30 +0000 (09:35 +0000)]
Configure: fixed "make" used instead of "${MAKE}".

13 years agoCorrected $request_length calculation for pipelined requests.
Andrey Belov [Fri, 6 Jul 2012 04:27:06 +0000 (04:27 +0000)]
Corrected $request_length calculation for pipelined requests.

13 years agoFixed typo in a function name.
Ruslan Ermilov [Tue, 3 Jul 2012 13:06:40 +0000 (13:06 +0000)]
Fixed typo in a function name.

13 years agoMade sure to initialize the entire "struct flock" allocated on stack.
Ruslan Ermilov [Tue, 3 Jul 2012 13:05:18 +0000 (13:05 +0000)]
Made sure to initialize the entire "struct flock" allocated on stack.

13 years agoReset r->uri_changed in a named location (ticket #184).
Maxim Dounin [Tue, 3 Jul 2012 11:30:05 +0000 (11:30 +0000)]
Reset r->uri_changed in a named location (ticket #184).

13 years agoTypo fixed.
Maxim Dounin [Tue, 3 Jul 2012 11:28:54 +0000 (11:28 +0000)]
Typo fixed.

13 years agomap: strip final dot before looking up in a map of hostnames.
Ruslan Ermilov [Fri, 29 Jun 2012 20:33:26 +0000 (20:33 +0000)]
map: strip final dot before looking up in a map of hostnames.
(closes #182)

13 years agoVersion bump.
Ruslan Ermilov [Fri, 29 Jun 2012 11:03:01 +0000 (11:03 +0000)]
Version bump.

13 years agorelease-1.3.2 tag
Maxim Dounin [Tue, 26 Jun 2012 13:46:53 +0000 (13:46 +0000)]
release-1.3.2 tag

13 years agonginx-1.3.2-RELEASE release-1.3.2
Maxim Dounin [Tue, 26 Jun 2012 13:46:23 +0000 (13:46 +0000)]
nginx-1.3.2-RELEASE

13 years agoMp4: fixed build on win32 after r4689.
Maxim Dounin [Tue, 26 Jun 2012 12:31:40 +0000 (12:31 +0000)]
Mp4: fixed build on win32 after r4689.

13 years agoAdded code to look up Google perftools in /opt/local/, for MacPorts.
Ruslan Ermilov [Tue, 26 Jun 2012 08:15:40 +0000 (08:15 +0000)]
Added code to look up Google perftools in /opt/local/, for MacPorts.

13 years agoStyle.
Maxim Dounin [Mon, 25 Jun 2012 18:09:38 +0000 (18:09 +0000)]
Style.

13 years agoIncorrect tag release-1.2.1 removed.
Maxim Dounin [Mon, 25 Jun 2012 15:30:17 +0000 (15:30 +0000)]
Incorrect tag release-1.2.1 removed.

Changes to misc/GNUmakefile was missed during stable-1.2 branch
creation, resulting in tag set on trunk, not on branch.

Reported by Marcel Gmuer.

13 years agoFixed a harmless error in spelling of "Connection: close" when computing
Ruslan Ermilov [Mon, 25 Jun 2012 13:08:25 +0000 (13:08 +0000)]
Fixed a harmless error in spelling of "Connection: close" when computing
the response header length.

13 years agoFixed compile-time conditionals used to detect if X-Forwarded-For support
Ruslan Ermilov [Thu, 21 Jun 2012 11:02:22 +0000 (11:02 +0000)]
Fixed compile-time conditionals used to detect if X-Forwarded-For support
is needed.

13 years agoDisabled gzip compression in OpenSSL prior to 1.0.0 version.
Igor Sysoev [Wed, 20 Jun 2012 12:55:28 +0000 (12:55 +0000)]
Disabled gzip compression in OpenSSL prior to 1.0.0 version.
This saves about 522K per connection.

13 years agoAdded IPv6 support to ip_hash.
Ruslan Ermilov [Tue, 19 Jun 2012 12:36:54 +0000 (12:36 +0000)]
Added IPv6 support to ip_hash.

13 years agoUpstream keepalive: "single" parameter deprecated.
Maxim Dounin [Mon, 18 Jun 2012 14:23:42 +0000 (14:23 +0000)]
Upstream keepalive: "single" parameter deprecated.

The original idea was to optimize edge cases in case of interchangeable
backends, i.e. don't establish a new connection if we have any one
cached.  This causes more harm than good though, as it screws up
underlying balancer's idea about backends used and may result in
various unexpected problems.

13 years agoFixed return type of ngx_strerror_init().
Maxim Dounin [Mon, 18 Jun 2012 14:12:03 +0000 (14:12 +0000)]
Fixed return type of ngx_strerror_init().

13 years agoFixed "sendmsg() failed" alerts on HP-UX.
Maxim Dounin [Mon, 18 Jun 2012 14:11:29 +0000 (14:11 +0000)]
Fixed "sendmsg() failed" alerts on HP-UX.

HP-UX needs _HPUX_ALT_XOPEN_SOCKET_API to be defined to be able to
use various POSIX versions of networking functions.  Notably sendmsg()
resulted in "sendmsg() failed (9: Bad file number)" alerts without it.

See xopen_networking(7) for more details.

13 years agoFixed segfault with poll and resolver used.
Maxim Dounin [Mon, 18 Jun 2012 14:10:50 +0000 (14:10 +0000)]
Fixed segfault with poll and resolver used.

Poll event method needs ngx_cycle->files to work, and use of ngx_exit_cycle
without files set caused null pointer dereference in resolver's cleanup
on udp socket close.

13 years agoChanged default alignment to 16.
Maxim Dounin [Mon, 18 Jun 2012 14:09:54 +0000 (14:09 +0000)]
Changed default alignment to 16.

This fixes alignment problems observerd on ARMs, and likely also needed
for MIPSes.  Unless we know alignment is not required just assume we
need 16, which appears to be safe default for all architectures.

See here for details:
http://mailman.nginx.org/pipermail/nginx/2012-June/034139.html

13 years agoFixed handling of conflicting wildcard server names.
Maxim Dounin [Mon, 18 Jun 2012 14:06:00 +0000 (14:06 +0000)]
Fixed handling of conflicting wildcard server names.

With previous code wildcard names were added to hash even if conflict
was detected.  This resulted in identical names in hash and segfault
later in ngx_hash_wildcard_init().

13 years agoMp4: fixed streaming if moov atom is at buffer edge.
Maxim Dounin [Mon, 18 Jun 2012 14:02:20 +0000 (14:02 +0000)]
Mp4: fixed streaming if moov atom is at buffer edge.

13 years agoMp4: fixed non-keyframe seeks in some cases (ticket #175).
Maxim Dounin [Mon, 18 Jun 2012 14:01:18 +0000 (14:01 +0000)]
Mp4: fixed non-keyframe seeks in some cases (ticket #175).

Number of entries in stsc atom was wrong if we've added an entry to
split a chunk.

Additionally, there is no need to add an entry if we are going to split
last chunk in an entry, it's enough to update the entry we already have.
Previously new entry was added and old one was left as is, resulting in
incorrect entry with zero chunks which might confuse some software.

13 years agoStyle fix.
Andrey Belov [Mon, 18 Jun 2012 13:51:20 +0000 (13:51 +0000)]
Style fix.

13 years agoNew core variable: $status.
Andrey Belov [Mon, 18 Jun 2012 13:43:44 +0000 (13:43 +0000)]
New core variable: $status.

Contains response status code as a 3-digit integer
(with leading zeroes if necessary), or one of the following values:

    000 - response status code has not yet been assigned
    009 - HTTP/0.9 request is being processed

13 years agoWhen "resolver" is configured with a domain name, only the first
Ruslan Ermilov [Mon, 18 Jun 2012 12:46:05 +0000 (12:46 +0000)]
When "resolver" is configured with a domain name, only the first
resolved address was used.  Now all addresses will be used.

13 years agoFixed crash in ngx_resolver_cleanup_tree().
Ruslan Ermilov [Mon, 18 Jun 2012 12:30:45 +0000 (12:30 +0000)]
Fixed crash in ngx_resolver_cleanup_tree().

If sending a DNS request fails with an error (e.g., when mistakenly trying
to send it to a local IP broadcast), such a request is not deleted if there
are clients waiting on it.  However, it was still erroneously removed from
the queue.  Later ngx_resolver_cleanup_tree() attempted to remove it from
the queue again that resulted in a NULL pointer dereference.

13 years agoVersion bump.
Ruslan Ermilov [Mon, 18 Jun 2012 11:07:44 +0000 (11:07 +0000)]
Version bump.

13 years agoFixed spelling of "endianness", and called it "byte ordering" in the
Ruslan Ermilov [Fri, 8 Jun 2012 09:41:55 +0000 (09:41 +0000)]
Fixed spelling of "endianness", and called it "byte ordering" in the
user visible part.

13 years agorelease-1.2.1 tag
Maxim Dounin [Tue, 5 Jun 2012 14:02:03 +0000 (14:02 +0000)]
release-1.2.1 tag

13 years agorelease-1.3.1 tag
Maxim Dounin [Tue, 5 Jun 2012 13:47:50 +0000 (13:47 +0000)]
release-1.3.1 tag

13 years agonginx-1.3.1-RELEASE release-1.3.1
Maxim Dounin [Tue, 5 Jun 2012 13:47:29 +0000 (13:47 +0000)]
nginx-1.3.1-RELEASE

13 years agoWin32: uris with ":$" are now rejected.
Maxim Dounin [Tue, 5 Jun 2012 13:38:27 +0000 (13:38 +0000)]
Win32: uris with ":$" are now rejected.

There are too many problems with special NTFS streams, notably "::$data",
"::$index_allocation" and ":$i30:$index_allocation".

For now we don't reject all URIs with ":" like Apache does as there are no
good reasons seen yet, and there are multiple programs using it in URLs
(e.g. MediaWiki).

13 years agoWin32: normalization of trailing dot inside uri.
Maxim Dounin [Tue, 5 Jun 2012 13:37:29 +0000 (13:37 +0000)]
Win32: normalization of trailing dot inside uri.

Windows treats "/directory./" identical to "/directory/".  Do the same
when working on Windows.  Note that the behaviour is different from one
with last path component (where multiple spaces and dots are ignored by
Windows).

13 years agoWin32: disallowed access to various non-canonical name variants.
Maxim Dounin [Tue, 5 Jun 2012 13:36:09 +0000 (13:36 +0000)]
Win32: disallowed access to various non-canonical name variants.

This includes trailings dots and spaces, NTFS streams (and short names, as
previously checked).  The checks are now also done in ngx_file_info(), thus
allowing to use the "try_files" directive to protect external scripts.

13 years agoSupport for IPv6 literals and an optional port in resolver.
Ruslan Ermilov [Mon, 4 Jun 2012 14:23:27 +0000 (14:23 +0000)]
Support for IPv6 literals and an optional port in resolver.

13 years agoSupport for IPv6 literals in proxy_pass and so on.
Maxim Dounin [Mon, 4 Jun 2012 14:07:34 +0000 (14:07 +0000)]
Support for IPv6 literals in proxy_pass and so on.

13 years agoUpstream: least_conn compilation fixes.
Maxim Dounin [Mon, 4 Jun 2012 00:00:28 +0000 (00:00 +0000)]
Upstream: least_conn compilation fixes.

Removed duplicate call of ngx_http_upstream_init_round_robin_peer()
overlooked during code changes.  Rewritten "return lcp->free_rr_peer(...)"
as MSVC doesn't like it.

13 years agoUpstream: weights support in ip_hash balancer.
Maxim Dounin [Sun, 3 Jun 2012 23:22:41 +0000 (23:22 +0000)]
Upstream: weights support in ip_hash balancer.

13 years agoUpstream: least_conn balancer module.
Maxim Dounin [Sun, 3 Jun 2012 23:21:26 +0000 (23:21 +0000)]
Upstream: least_conn balancer module.

13 years agoResolver: fixed format specification.
Maxim Dounin [Sun, 3 Jun 2012 23:18:24 +0000 (23:18 +0000)]
Resolver: fixed format specification.

Patch by Yichun Zhang (agentzh).

13 years agoCode reduction (no functional changes).
Ruslan Ermilov [Fri, 1 Jun 2012 11:35:09 +0000 (11:35 +0000)]
Code reduction (no functional changes).

13 years agoRemoved mistaken setting of NGX_SSL_BUFFERED flag in ngx_ssl_send_chain()
Valentin Bartenev [Wed, 30 May 2012 12:43:27 +0000 (12:43 +0000)]
Removed mistaken setting of NGX_SSL_BUFFERED flag in ngx_ssl_send_chain()
if SSL buffer is not used.

13 years agoFixed returned value handling from the cookie rewrite handler.
Valentin Bartenev [Wed, 30 May 2012 12:30:03 +0000 (12:30 +0000)]
Fixed returned value handling from the cookie rewrite handler.

If the "proxy_cookie_domain" or "proxy_cookie_path" directive is used and there
are no matches in Set-Cookie header then ngx_http_proxy_rewrite_cookie() returns
NGX_DECLINED to indicate that the header was not rewritten. Returning this value
further from the upstream headers copy handler resulted in 500 error response.

See here for report:
http://mailman.nginx.org/pipermail/nginx/2012-May/033858.html

13 years agogeoip: got rid of ugly casts when calling ngx_free().
Ruslan Ermilov [Tue, 29 May 2012 09:19:51 +0000 (09:19 +0000)]
geoip: got rid of ugly casts when calling ngx_free().

This is done by removing the "const" qualifier from the common return
type of handler functions returning either "const char *" or "char *".

13 years agoFixed broken build.
Ruslan Ermilov [Mon, 28 May 2012 14:20:04 +0000 (14:20 +0000)]
Fixed broken build.

13 years agoFixed memory leak if $geoip_org variable was used.
Ruslan Ermilov [Mon, 28 May 2012 13:17:48 +0000 (13:17 +0000)]
Fixed memory leak if $geoip_org variable was used.

Patch by Denis F. Latypoff (slightly modified).

13 years agoFixed the reuse of parsed DTDs and XSLTs.
Ruslan Ermilov [Thu, 24 May 2012 07:35:12 +0000 (07:35 +0000)]
Fixed the reuse of parsed DTDs and XSLTs.

Patch by Kuramoto Eiji.

13 years agoFixed compilation with -DNGX_DEBUG_MALLOC on FreeBSD 10.
Maxim Dounin [Wed, 23 May 2012 15:07:01 +0000 (15:07 +0000)]
Fixed compilation with -DNGX_DEBUG_MALLOC on FreeBSD 10.

After jemalloc 3.0.0 import there is no _malloc_options symbol, it has
been replaced with the malloc_conf one with a different syntax.

13 years agoFixed warning during nginx.xs compilation.
Maxim Dounin [Wed, 23 May 2012 10:36:12 +0000 (10:36 +0000)]
Fixed warning during nginx.xs compilation.

13 years agoFixed potential null pointer dereference in ngx_resolver_create().
Ruslan Ermilov [Tue, 22 May 2012 13:12:14 +0000 (13:12 +0000)]
Fixed potential null pointer dereference in ngx_resolver_create().
While here, improved error message.

13 years agoRemoved historical and now redundant syntax pre-checks in ngx_parse_url().
Ruslan Ermilov [Mon, 21 May 2012 10:55:10 +0000 (10:55 +0000)]
Removed historical and now redundant syntax pre-checks in ngx_parse_url().

13 years agoFixed core variables dynamic access after reconfiguration.
Maxim Dounin [Thu, 17 May 2012 18:10:34 +0000 (18:10 +0000)]
Fixed core variables dynamic access after reconfiguration.

If variable was indexed in previous configuration but not in current
one, the NGX_HTTP_VAR_INDEXED flag was left set and confused
ngx_http_get_variable().

Patch by Yichun Zhang (agentzh), slightly modified.

13 years agoFixed segfault with filter_finalize introduced in r4621 (1.3.0).
Maxim Dounin [Thu, 17 May 2012 17:41:40 +0000 (17:41 +0000)]
Fixed segfault with filter_finalize introduced in r4621 (1.3.0).

Example configuration to reproduce:

    location /image/ {
        error_page 415 = /zero;
        image_filter crop 100 100;
        proxy_pass http://127.0.0.1:8080;
        proxy_store on;
    }

    location /zero {
        return 204;
    }

The problem appeared if upstream returned (big enough) non-image file,
causing 415 to be generated by image filter.

13 years agoFixed building --with-cpp_test_module on some systems.
Valentin Bartenev [Thu, 17 May 2012 15:12:45 +0000 (15:12 +0000)]
Fixed building --with-cpp_test_module on some systems.

13 years agoFixed the ngx_regex.h header file compatibility with C++.
Valentin Bartenev [Thu, 17 May 2012 13:47:04 +0000 (13:47 +0000)]
Fixed the ngx_regex.h header file compatibility with C++.

13 years agoZero padded the returned and logged HTTP status code, and fixed possible
Ruslan Ermilov [Wed, 16 May 2012 13:27:04 +0000 (13:27 +0000)]
Zero padded the returned and logged HTTP status code, and fixed possible
buffer overrun in $status handling.

13 years agoCapped the status code that may be returned with "return" and "try_files".
Ruslan Ermilov [Wed, 16 May 2012 13:22:03 +0000 (13:22 +0000)]
Capped the status code that may be returned with "return" and "try_files".

13 years agoAdded syntax checking of the second parameter of the "split_clients" directive.
Ruslan Ermilov [Wed, 16 May 2012 13:14:53 +0000 (13:14 +0000)]
Added syntax checking of the second parameter of the "split_clients" directive.

13 years agoVersion bump.
Ruslan Ermilov [Wed, 16 May 2012 13:09:39 +0000 (13:09 +0000)]
Version bump.

14 years agorelease-1.3.0 tag
Maxim Dounin [Tue, 15 May 2012 14:24:09 +0000 (14:24 +0000)]
release-1.3.0 tag

14 years agonginx-1.3.0-RELEASE release-1.3.0
Maxim Dounin [Tue, 15 May 2012 14:23:49 +0000 (14:23 +0000)]
nginx-1.3.0-RELEASE

14 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Tue, 15 May 2012 14:20:06 +0000 (14:20 +0000)]
Updated OpenSSL used for win32 builds.

14 years agoFixed win32 build after changes in r4624.
Ruslan Ermilov [Tue, 15 May 2012 08:10:59 +0000 (08:10 +0000)]
Fixed win32 build after changes in r4624.

14 years agoUpdate c->sent in ngx_ssl_send_chain() even if SSL buffer is not used.
Valentin Bartenev [Mon, 14 May 2012 16:30:33 +0000 (16:30 +0000)]
Update c->sent in ngx_ssl_send_chain() even if SSL buffer is not used.

14 years agoReverted previous attempt to fix complation warning introduced in
Ruslan Ermilov [Mon, 14 May 2012 15:52:37 +0000 (15:52 +0000)]
Reverted previous attempt to fix complation warning introduced in
r4624 and actually fixed it.

14 years agogeoip: trusted proxies support and partial IPv6 support.
Ruslan Ermilov [Mon, 14 May 2012 14:00:17 +0000 (14:00 +0000)]
geoip: trusted proxies support and partial IPv6 support.

The module now supports recursive search of client address through the
chain of trusted proxies (closes #100), in the same scope as the geo
module.  Proxies are listed by the "geoip_proxy" directive, recursive
search is enabled by the "geoip_proxy_recursive" directive.  IPv6 is
partially supported: proxies may be specified with IPv6 addresses.

Example:
    geoip_country .../GeoIP.dat;
    geoip_proxy 127.0.0.1;
    geoip_proxy ::1;
    geoip_proxy 10.0.0.0/8;
    geoip_proxy_recursive on;

14 years agogeo: chains of trusted proxies and partial IPv6 support.
Ruslan Ermilov [Mon, 14 May 2012 13:53:22 +0000 (13:53 +0000)]
geo: chains of trusted proxies and partial IPv6 support.

The module now supports recursive search of client address through
the chain of trusted proxies, controlled by the "proxy_recursive"
directive in the "geo" block.  It also gets partial IPv6 support:
now proxies may be specified with IPv6 addresses.

Example:
    geo $test {
        ...
        proxy 127.0.0.1;
        proxy ::1;
        proxy_recursive;
    }

There's also a slight change in behavior.  When original client
address (as specified by the "geo" directive) is one of the
trusted proxies, and the value of the X-Forwarded-For request
header cannot not be parsed as a valid address, an original client
address will be used for lookup.  Previously, 255.255.255.255 was
used in this case.

14 years agoFixed compilation warning introduced in r4624.
Ruslan Ermilov [Mon, 14 May 2012 13:15:22 +0000 (13:15 +0000)]
Fixed compilation warning introduced in r4624.

14 years agorealip: chains of trusted proxies and IPv6 support.
Ruslan Ermilov [Mon, 14 May 2012 12:41:03 +0000 (12:41 +0000)]
realip: chains of trusted proxies and IPv6 support.

The module now supports recursive search of client address through
the chain of trusted proxies, controlled by the "real_ip_recursive"
directive (closes #2).  It also gets full IPv6 support (closes #44)
and canonical value of the $client_addr variable on address change.

Example:
    real_ip_header X-Forwarded-For;
    set_real_ip_from 127.0.0.0/8;
    set_real_ip_from ::1;
    set_real_ip_from unix:;
    real_ip_recursive on;

14 years agoNew function ngx_http_get_forwarded_addr() to look up real client address.
Ruslan Ermilov [Mon, 14 May 2012 12:27:41 +0000 (12:27 +0000)]
New function ngx_http_get_forwarded_addr() to look up real client address.

On input it takes an original address, string in the X-Forwarded-For format
and its length, list of trusted proxies, and a flag indicating to perform
the recursive search.  On output it returns NGX_OK and the "deepest" valid
address in a chain, or NGX_DECLINED.  It supports AF_INET and AF_INET6.
Additionally, original address and/or proxy may be specified as AF_UNIX.

14 years agoUpstream: fixed ip_hash rebalancing with the "down" flag.
Maxim Dounin [Mon, 14 May 2012 09:58:07 +0000 (09:58 +0000)]
Upstream: fixed ip_hash rebalancing with the "down" flag.

Due to weight being set to 0 for down peers, order of peers after sorting
wasn't the same as without the "down" flag (with down peers at the end),
resulting in client rebalancing for clients on other servers.  The only
rebalancing which should happen after adding "down" to a server is one
for clients on the server.

The problem was introduced in r1377 (which fixed endless loop by setting
weight to 0 for down servers).  The loop is no longer possible with new
smooth algorithm, so preserving original weight is safe.

14 years agoUpstream: smooth weighted round-robin balancing.
Maxim Dounin [Mon, 14 May 2012 09:57:20 +0000 (09:57 +0000)]
Upstream: smooth weighted round-robin balancing.

For edge case weights like { 5, 1, 1 } we now produce { a, a, b, a, c, a, a }
sequence instead of { c, b, a, a, a, a, a } produced previously.

Algorithm is as follows: on each peer selection we increase current_weight
of each eligible peer by its weight, select peer with greatest current_weight
and reduce its current_weight by total number of weight points distributed
among peers.

In case of { 5, 1, 1 } weights this gives the following sequence of
current_weight's:

     a  b  c
     0  0  0  (initial state)

     5  1  1  (a selected)
    -2  1  1

     3  2  2  (a selected)
    -4  2  2

     1  3  3  (b selected)
     1 -4  3

     6 -3  4  (a selected)
    -1 -3  4

     4 -2  5  (c selected)
     4 -2 -2

     9 -1 -1  (a selected)
     2 -1 -1

     7  0  0  (a selected)
     0  0  0

To preserve weight reduction in case of failures the effective_weight
variable was introduced, which usually matches peer's weight, but is
reduced temporarily on peer failures.

This change also fixes loop with backup servers and proxy_next_upstream
http_404 (ticket #47), and skipping alive upstreams in some cases if there
are multiple dead ones (ticket #64).

14 years agoFixed possible request hang with filter finalization.
Maxim Dounin [Mon, 14 May 2012 09:48:05 +0000 (09:48 +0000)]
Fixed possible request hang with filter finalization.

With r->filter_finalize set the ngx_http_finalize_connection() wasn't
called from ngx_http_finalize_request() called with NGX_OK, resulting in
r->main->count not being decremented, thus causing request hang in some
rare situations.

See here for more details:
http://mailman.nginx.org/pipermail/nginx-devel/2012-May/002190.html

Patch by Yichun Zhang (agentzh).

14 years agoResolver: protection from duplicate responses.
Maxim Dounin [Mon, 14 May 2012 09:13:45 +0000 (09:13 +0000)]
Resolver: protection from duplicate responses.

If we already had CNAME in resolver node (i.e. rn->cnlen and rn->u.cname
set), and got additional response with A record, it resulted in rn->cnlen
set and rn->u.cname overwritten by rn->u.addr (or rn->u.addrs), causing
segmentation fault later in ngx_resolver_free_node() on an attempt to free
overwritten rn->u.cname.  The opposite (i.e. CNAME got after A) might cause
similar problems as well.

14 years agoAccept moderation in case of EMFILE/ENFILE.
Maxim Dounin [Fri, 11 May 2012 13:33:06 +0000 (13:33 +0000)]
Accept moderation in case of EMFILE/ENFILE.

In case of EMFILE/ENFILE returned from accept() we disable accept events,
and (in case of no accept mutex used) arm timer to re-enable them later.
With accept mutex we just drop it, and rely on normal accept mutex handling
to re-enable accept events once it's acquired again.

As we now handle errors in question, logging level was changed to "crit"
(instead of "alert" used for unknown errors).

Note: the code might call ngx_enable_accept_events() multiple times if
there are many listen sockets.  The ngx_enable_accept_events() function was
modified to check if connection is already active (via c->read->active) and
skip it then, thus making multiple calls safe.

14 years agoRewrite: fixed escaping and possible segfault (ticket #162).
Maxim Dounin [Fri, 11 May 2012 13:19:22 +0000 (13:19 +0000)]
Rewrite: fixed escaping and possible segfault (ticket #162).

The following code resulted in incorrect escaping of uri and possible
segfault:

    location / {
        rewrite ^(.*) $1?c=$1;
        return 200 "$uri";
    }

If there were arguments in a rewrite's replacement string, and length was
actually calculated (due to duplicate captures as in the example above,
or variables present), the is_args flag was set and incorrectly copied
after length calculation.  This resulted in escaping applied to the uri part
of the replacement, resulting in incorrect escaping.  Additionally, buffer
was allocated without escaping expected, thus this also resulted in buffer
overrun and possible segfault.

14 years agoFastcgi: fixed padding handling on fixed-size records.
Maxim Dounin [Fri, 11 May 2012 13:14:58 +0000 (13:14 +0000)]
Fastcgi: fixed padding handling on fixed-size records.

Padding was incorrectly ignored on end request, empty stdout and stderr
fastcgi records.  This resulted in protocol desynchronization if fastcgi
application used these records with padding for some reason.

Reported by Ilia Vinokurov.

14 years agoAdded r->state reset on fastcgi/scgi/uwsgi request start.
Maxim Dounin [Fri, 11 May 2012 13:09:24 +0000 (13:09 +0000)]
Added r->state reset on fastcgi/scgi/uwsgi request start.

Failing to do so results in problems if 400 or 414 requests are
redirected to fastcgi/scgi/uwsgi upstream, as well as after invalid
headers got from upstream.  This was already fixed for proxy in r3478,
but fastcgi (the only affected protocol at that time) was missed.

Reported by Matthieu Tourne.

14 years agoAdded write event handler reset in ngx_http_named_location().
Maxim Dounin [Fri, 4 May 2012 11:35:22 +0000 (11:35 +0000)]
Added write event handler reset in ngx_http_named_location().

On internal redirects this happens via ngx_http_handler() call, which is
not called on named location redirect.  As a result incorrect write handler
remained (if previously set) and this might cause incorrect behaviour (likely
request hang).

Patch by Yichun Zhang (agentzh).

14 years agodebug_connection: added the IPv6 and UNIX-domain socket support.
Ruslan Ermilov [Sun, 29 Apr 2012 22:02:18 +0000 (22:02 +0000)]
debug_connection: added the IPv6 and UNIX-domain socket support.

14 years agoRemoved surplus condition.
Valentin Bartenev [Fri, 27 Apr 2012 10:48:42 +0000 (10:48 +0000)]
Removed surplus condition.