Opened 7 years ago

Closed 7 years ago

#1155 closed defect (invalid)

upstream definition not working in nginx for windows

Reported by: roundand@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.11.x
Keywords: upstream Cc:
uname -a: [>ver] Microsoft Windows [Version 6.3.9600]
nginx -V: nginx version: nginx/1.11.5
built by cl 16.00.30319.01 for 80x86
built with OpenSSL 1.0.2j 26 Sep 2016
TLS SNI support enabled
configure arguments: --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access
.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fast
cgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msv
c8/lib/pcre-8.39 --with-zlib=objs.msvc8/lib/zlib-1.2.8 --with-select_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-
http_dav_module --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-htt
p_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail --with-stream --with-openssl=objs.msvc
8/lib/openssl-1.0.2j --with-openssl-opt=no-asm --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module

Description

I am using this config file to route all requests to a public echo service:

#user  nobody;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    error_log error.log debug;

	upstream app_server {
		server rve.org.uk;
	}

    server {
        listen       80 default_server;
        server_name  localhost;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection '';
        proxy_cache_bypass $http_upgrade;
        proxy_pass_request_headers      on;

		location / {
		  proxy_pass http://rve.org.uk/utils/echo-nocache.cgi/freg/;
#		  proxy_pass http://app_server/utils/echo-nocache.cgi/freg/;
		}
	}
}

As is, this works:

$ curl 127.0.0.1
GET /utils/echo-nocache.cgi/freg/ HTTP/1.1
Host: rve.org.uk
User-Agent: curl/7.49.1
Accept: */*

But when I change the proxy_pass value to reference "app_server" as defined in the upstream directive, I get a 403:

$ curl 127.0.0.1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /utils/echo-nocache.cgi/freg/
on this server.</p>
</body></html>

Am I misusing "upstream" or is this a bug?

Change History (2)

comment:1 by roundand@…, 7 years ago

I am getting similar behaviour running against the default nginx image on Docker Hub, using docker-machine and virtualbox to host this locally.

comment:2 by Maxim Dounin, 7 years ago

Resolution: invalid
Status: newclosed

This is what your upstream server returns. Note that using different name in the proxy_pass directive also implies using different Host in the request, see http://nginx.org/r/proxy_set_header.

Please use mailing list if you have other questions.

Note: See TracTickets for help on using tickets.