Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i'm trying to get custom language and message for nginx error page but keep url on browser.. not success for eg: i go to url : on the time server down.. nginx will show error 502. with the same url but custom message as my language.

test 1.
I created a custom page at /usr/local/nginx/html/205.html

as following config but it show on web site when error is default nginx error at ( the content of webpage not same as i created)

error_page 502 /502.html;
location = /502.html {
root /usr/local/nginx/html;

test 2. Then i create same page at my www domain folder /home/xaluano/public_html/502.html but this keep redirect me to root the content now same as i created. but.. the url still not as i need

error_page 502 /502.html;
location = /502.html {
root /home/xaluano/public_html;

EDIT UPDATE for more detail 10/06/2012 please download my nginx config and vhost config following:

== the case test..

if apache httpd service stop: #service httpd stop

then open browser go to:

I will see the 502 error with the same url on browser address

== Custome error page I need the config which help when apache fail .. will show the custom message tell user wail for 1 minute for service back then refress current page with same url ( refresh I can do easy by javascript ), Nginx dosent change url so java-script can work out.

any help will be great.. thank in advance

share|improve this question
nginx doesn't sent an HTTP redirect on 502 errors by default, so you need to find out what is sending that. – mgorven Jun 10 '12 at 2:56

You can try this one

location / (
error_page 502 @fallback;

location @fallback (
proxy_pass http://backend;

This will do not change a browser's url


share|improve this answer
thanks for help. but where i can put my custom message ? I have read wiki but seem it too hard 2 understand 4 me :( – user123862 Jun 7 '12 at 10:38
@user123862 if your custom 502 page is in, just use it like proxy_pass i can't sure it works but maybe. – Deminoth Bono Jun 7 '12 at 12:43
i test with .. proxy_pass; but config not even pass the reload of nginx test – user123862 Jun 8 '12 at 0:54
I have update detail config to basebin could you have look. thanks – user123862 Jun 10 '12 at 2:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.