ïÂÒÁÂÏÔËÁ ÏÛÉÂÏË × ÏÔÄÅÌØÎÏÍ backendÅ.
igor.goncharenko
nginx-forum ÎÁ nginx.us
÷Ô ñÎ× 19 16:37:43 MSK 2010
Hi!
èÏÞÕ ÏÂÒÁÂÁÔÙ×ÁÔØ ×ÓÅ 50x ÏÛÉÂËÉ ÏÔ ÂÜËÅÎÄÏ× × ÏÔÄÅÌØÎÏÍ ÂÜËÅÎÄÅ. ÷ ÜÔÏÍ ÏÔÄÅÌØÎÏÍ ÂÜËÅÎÄÅ ÈÏÞÕ ×Ù×ÏÄÉÔØ ÒÁÚÎÙÅ custom ÓÔÒÁÎÉÃÙ × ÚÁ×ÉÓÉÍÏÓÔÉ ÏÔ ÏÛÉÂËÉ É location.
óÄÅÌÁÌ ÔÁË:
--vhost config--
upstream backends {
server first.backend.com:80;
server second.backend.com:80;
}
server
{
listen bla-bla:80;
server_name bla-bla.com;
location /
{
proxy_pass http://backends;
}
# ÐÒÉ 50x ÉÄÅÍ × ÉÍÅÎÏ×ÁÎÎÙÊ location
error_page 500 502 503 504 @error_pages_back;
{skip}
# ÉÍÅÎÏ×ÁÎÙÊ location Ó ÐÒÏËÓÉÒÏ×ÁÎÉÅÍ ÎÁ ÂÜËÅÎÄ
# ÄÌÑ ÏÂÒÁÂÏÔËÉ ÏÛÉÂËÉ
location @error_pages_back {
proxy_intercept_errors on;
recursive_error_pages on;
proxy_pass http://127.0.0.1:9876;
proxy_set_header Host $host;
proxy_buffering off;
proxy_cache off;
}
}
---vhost config---
ÔÅÐÅÒØ ËÏÎÆÉÇ ÂÜËÅÎÄÁ, × ËÏÔÏÒÏÍ ×ÏÐÒÏÓ - ËÁË ÜÔÏ ÓÄÅÌÁÔØ :)
åÓÌÉ Ñ ÕËÁÚÙ×ÁÀ return 50x × ÎÕÖÎÏÍ location, ÔÏ ÜÔÏ ÒÁÂÏÔÁÅÔ, ÎÏ ÎÅÔ Ó×ÑÚÉ Ó ÏÒÉÇÉÎÁÌØÎÏÊ ÏÛÉÂËÏÊ (ÜÔÏ É ÐÏÎÑÔÎÏ, ÞÔÏ ÓËÁÚÁÌ × return, ÔÏ É ÏÔÄÁÌÉ). ïÄÎÁËÏ, ÅÓÌÉ Ñ ÎÅ ÉÓÐÏÌØÚÕÀ return, ÔÏ ËÁËÉÍ ÏÂÒÁÚÏÍ ÍÎÅ ÐÒÏ×ÅÒÉÔØ × ÂÜËÅÎÄÅ ÎÏÍÅÒ ÏÒÉÇÉÎÁÌØÎÏÊ ÏÛÉÂËÉ É ÐÏÔÏÍ ×Ù×ÅÓÔÉ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ 50x.html?
server
{
listen 127.0.0.1:9876;
server_name localhost;
index 500.html;
root /usr/local/www/error_pages;
access_log /var/log/nginx/errors/access.log main;
error_log /var/log/nginx/errors/error.log notice;
location /error_pages/ {
root /usr/local/www;
internal;
}
error_page 500 502 503 504 /error_pages/500.html;
location /
{
return 502;
}
location /xhtml
{
return 502;
error_page 500 503 504 /error_pages/xhtml500.html;
error_page 502 /error_pages/xhtml502.html;
}
}
PS. nginx-0.7.64
Posted at Nginx Forum: http://forum.nginx.org/read.php?21,43006,43006#msg-43006
ðÏÄÒÏÂÎÁÑ ÉÎÆÏÒÍÁÃÉÑ Ï ÓÐÉÓËÅ ÒÁÓÓÙÌËÉ nginx-ru