asp.net mvc - Nginx to iis forwarding Error 400 -


please me. have iis server , nginx proxy on it. when connected nginx 400 bad request (invalid hostname) error , when press f5 , reload page site loading correct (200 code) without scripts\css... , when press f5 angain 400 error , on.

iis on http://localhost:81

i tried 2 nginx configs:

first

  location / {             proxy_pass http://localhost:81;             proxy_set_header    host            $host;             proxy_set_header    x-real-ip       $remote_addr;             proxy_set_header    x-forwarded-for $remote_addr;             port_in_redirect off;             proxy_connect_timeout 300;         } 

second

 location / {             proxy_pass http://localhost:81;             proxy_set_header host $host;             proxy_set_header x-accel-expires 0;             proxy_set_header x-real-ip $remote_addr;             proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;         } 

both first , second config have error. nginx of 1.6.2 version.

nginx error.log empty. nginx access log this

217.66.152.89 - - [16/mar/2015:23:42:56 +0300] "get / http/1.1" 400 334 "-" "mozilla/5.0 (windows nt 6.3; wow64) applewebkit/537.36 (khtml, gecko) chrome/41.0.2272.89 safari/537.36" 217.66.152.89 - - [16/mar/2015:23:42:58 +0300] "get / http/1.1" 200 689 "-" "mozilla/5.0 (windows nt 6.3; wow64) applewebkit/537.36 (khtml, gecko) chrome/41.0.2272.89 safari/537.36" 217.66.152.89 - - [16/mar/2015:23:43:01 +0300] "get / http/1.1" 400 334 "-" "mozilla/5.0 (windows nt 6.3; wow64) applewebkit/537.36 (khtml, gecko) chrome/41.0.2272.89 safari/537.36" 217.66.152.89 - - [16/mar/2015:23:43:03 +0300] "get / http/1.1" 200 689 "-" "mozilla/5.0 (windows nt 6.3; wow64) applewebkit/537.36 (khtml, gecko) chrome/41.0.2272.89 safari/537.36" 

iis logs have 200 , 304 codes

request headers

accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 accept-encoding:gzip, deflate, sdch accept-language:ru-ru,ru;q=0.8,en-us;q=0.6,en;q=0.4 cache-control:max-age=0 connection:keep-alive cookie:mode=undefined; view=undefined host:(this host) if-modified-since:mon, 16 mar 2015 12:56:48 gmt if-none-match:"4e905caae85fd01:0" user-agent:mozilla/5.0 (windows nt 6.3; wow64) applewebkit/537.36 (khtml, gecko) chrome/41.0.2272.89 safari/537.36 

i hope help.

had same issue. caused fact server dns name resolving ipv4 address only, when "localhost" had both ipv4 , ipv6.

when nginx tried resolve upstream "http://localhost" getting "::1" , switching ipv6 - http.sys (iis network layer sake of discussion) later got ipv4 address name specified in "host:" header.

this situation not handled, despite fact symbolic name, "localhost", ipv4 address , "::1" ipv6 1 belong same machine.

workaround - remove proxy_set_header host $host; directive or use numeric upstream address in proxy_pass uri.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -