MihaiM Asked: 2010-08-01 11:47:41 +0800 CST2010-08-01 11:47:41 +0800 CST 2010-08-01 11:47:41 +0800 CST Simulate 502 & 504 on nginx 772 Is there any way to simulate these errors? I created some custom files for it, but I want to be sure that are displayed correctly. I made different message for every vhost. Thank you in advance. http nginx 502 504 1 Answers Voted Best Answer Studer 2010-08-01T11:59:21+08:002010-08-01T11:59:21+08:00 You can setup a custom error page for every location block in your nginx.conf or a global error page for the site. Example for a 502 error : location /my_blog { error_page 502 = /502.html; return 502; } A global 502 error page : server { listen 80; error_page 502 /502.html; location /test { return 502; } } You can even append standard error codes together to have a single page for several types of errors : location /my_blog { error_page 500 502 503 504 = /server_error.html; ... } To redirect to a totally different server, assuming you had an upstream server named server2 defined in your http section: upstream server2 { server 10.0.0.1:80; } server { ... location /my_blog { error_page 502 = @try_server2; return 502; } location @try_server2 { proxy_pass http://server2; } } The manual can give you more details (there might be some others useful examples on the web).
You can setup a custom error page for every location block in your nginx.conf or a global error page for the site.
Example for a 502 error :
A global 502 error page :
You can even append standard error codes together to have a single page for several types of errors :
To redirect to a totally different server, assuming you had an upstream server named server2 defined in your http section:
The manual can give you more details (there might be some others useful examples on the web).