Opened 11 years ago

Closed 11 years ago

#276 closed defect (fixed)

nginx 1.3.10 sets wrong default port for 'proxy_pass' directive

Reported by: Andreas Jaggi Owned by: Ruslan Ermilov
Priority: major Milestone:
Component: nginx-core Version: 1.3.x
Keywords: Cc:
uname -a: Linux real.jaggi.info 2.6.32-5-amd64 #1 SMP Sun Sep 23 10:07:46 UTC 2012 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.3.10
TLS SNI support enabled
configure arguments: --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --
http-scgi-temp-path=/var/lib/nginx/scgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-htt
p_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_realip_module --with-http_perl_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-ipv6 --with-ma
il --with-mail_ssl_module --add-module=/root/naxsi-core-0.49/naxsi_src --add-module=/root/src/nginx-1.3.10/modules/nginx-upstream-fair --add-module=/root/src/nginx-1.3.10/modules/ngx_http_subs_filter_module --add-module=/root/src/nginx-1.3.
10/modules/ngx_devel_kit --add-module=/root/src/nginx-1.3.10/modules/ngx_http_set_misc_module --add-module=/root/src/nginx-1.3.10/modules/ngx_http_auth_request_module --add-module=/root/src/nginx-1.3.10/modules/ngx_http_headers_more_filter_
module --add-module=/root/src/nginx-1.3.10/modules/ngx_http_form_input_module --add-module=/root/src/nginx-1.3.10/modules/ngx_http_encrypted_session_module --add-module=/root/src/nginx-1.3.10/modules/ngx_http_echo_module --add-module=/root/
src/nginx-1.3.10/modules/ngx_http_set_hash_module --add-module=/root/src/nginx-1.3.10/modules/ngx_http_auth_pam_module --add-module=/root/my_ngx_modules/ngx_http_remote_passwd --add-module=/root/my_ngx_modules/ngx_http_filter_header

Description

After updating from nginx 1.3.8 to 1.3.10, the reverse proxy functionality of nginx is no longer working properly.

My configuration:

        location / { 
                proxy_set_header X-Forwarded-Host $host;
                proxy_set_header X-Forwarded-Server $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Real-IP $remote_addr;

                proxy_set_header Host links.x-way.org;
                proxy_pass https://77.37.18.97/;
        }


Sample log entries:

==> /var/log/nginx/links.x-way.org.error.log <==
2013/01/07 17:17:47 [error] 18026#0: *384 connect() failed (110: Connection timed out) while connecting to upstream, client: 216.151.139.39, server: links.x-way.org, request: "GET /register.php/ HTTP/1.0", upstream: "https://77.37.18.97:0/r
egister.php/", host: "links.x-way.org", referrer: "https://www.links.x-way.org/about.php/"

==> /var/log/nginx/links.x-way.org.access.log <==
216.151.139.39 - - [07/Jan/2013:17:17:47 +0100]  "GET /register.php/ HTTP/1.0" 502 568 "https://www.links.x-way.org/about.php/" "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1" 21.827

From the log file we see that it is using port '0' to access the 77.37.18.97 backend instead of port '443' (for https).

When explicitely specifing '443' as port in the proxy_pass directive like below, the connection to the backend works fine.

        location / {
                proxy_set_header X-Forwarded-Host $host;
                proxy_set_header X-Forwarded-Server $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Real-IP $remote_addr;

                proxy_set_header Host links.x-way.org;
                proxy_pass https://77.37.18.97:443/;
        }

So I guess, the problem is that the default port for the proxy_pass directive is no longer properly set (eg. 80 when proxy_pass starts with http:// and 443 when it starts with https://).

Change History (4)

comment:1 by Andreas Jaggi, 11 years ago

Looks like one of the following changes caused this:

  • r4970 Simplified URL parsing code
  • r4971 Fixed URL parsing code

comment:2 by maxim, 11 years ago

Owner: set to Ruslan Ermilov
Status: newassigned

comment:3 by Ruslan Ermilov, 11 years ago

In 5006/nginx:

(The changeset message doesn't reference this ticket)

comment:4 by Maxim Dounin, 11 years ago

Resolution: fixed
Status: assignedclosed

Fix is available in just released nginx 1.3.11. Thanks for reporting this!

Note: See TracTickets for help on using tickets.