Nginx – How to create custom content for nginx error 502 page, keep origin url on browser

nginx

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 : xaluan.com/aaa/bbb.html 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 domain.com/50.html ( 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 domain.com/502.html 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;
internal;
}

EDIT UPDATE for more detail 10/06/2012
please download my nginx config http://pastebin.com/7iLD6WQq
and vhost config following: http://pastebin.com/ZZ91KiY6

== the case test..

if apache httpd service stop: #service httpd stop

then open browser go to:

xaluan.com/modules.php?name=News&file=article&sid=123456

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

Best Answer

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

ref: http://wiki.nginx.org/HttpCoreModule#error_page