Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#192 closed defect (invalid)

504 Gateway Time-out for proxyed site after Server IP change

Reported by: Cenarius Owned by: somebody
Priority: minor Milestone:
Component: nginx-core Version: 1.3.x
Keywords: Cc:
uname -a: Windows 8 x64 Consumer Preview
nginx -V: nginx version: nginx/1.1.13

Description

I have this config:

server {
	listen			80;
	server_name		testsite.com;
	access_log		logs/access-testsite.com.log;
	error_log		logs/errors-testsite.com.log;

	location / {
		proxy_pass	http://testsite.com:81/;
	}
}

If Server IP changes while nginx is running you will get 504 Gateway Time-out when trying to go http://testsite.com/
After nginx is restarted, http://testsite.com/ works ok.

Change History (4)

comment:1 by Cenarius, 12 years ago

My internet connection is via PPPOE, don't know if it's important or not. When the PPPOE connection drops and reconnects, nginx throws 504 Gateway Time-out until restared.

comment:2 by Maxim Dounin, 12 years ago

Resolution: invalid
Status: newclosed

This is expected behaviour, as nginx resolves hostnames in configuration during configuration parsing. The old ip isn't reachable anymore after server ip change and requests directed to it will time out. You have to do configuration reload for nginx to re-resolve hostnames. You may also force dynamic resolution at runtime by using proxy_pass with variables and the resolver directive, but this isn't generally recommended.

comment:3 by Cenarius, 12 years ago

Setting config to

http {
	resolver 8.8.8.8 valid=60s;
	resolver_timeout 5s;
}

doesn't resolve this issue, any other advice ?

comment:4 by Maxim Dounin, 12 years ago

As already said, you have to use proxy_pass with variables for this to work.

Note: See TracTickets for help on using tickets.