Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP and reverse proxy

Newbie
 
Join Date: Jul 2008
Posts: 28
#1: Jul 4 '08
Hi,

I have setup a reverse proxy server which will route the request to
Server B. Proxy server is working well with Server B.

I would like to catch HTTP status error like 404/500 from server B. If my proxy gets error404/500 from Server B then it will redirect the page to other site, using PHP. For this reason, I set ErrorDocument 404/500 on httpd.conf file in reverse proxy
server to catch error from Server B. But ErrorDocument is not
working at all. it is working only if I request local file (in proxy server).

I would be glad if you kindly advise me how do I catch HTTP
status error code from Server B and redirect to custom error
page with requested url, using PHP.

Thanks

pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: Jul 4 '08

re: PHP and reverse proxy


Heya, kokababu.

How are you sending the requests? Are you using cURL?
Newbie
 
Join Date: Jul 2008
Posts: 28
#3: Jul 4 '08

re: PHP and reverse proxy


Hi,

I am not using cURL. I have set Proxypass and ProxyPassReverse
in httpd.conf file in my proxy server, let it is called proxyA.

I have also set a "ErrorDocument 404 /senderror.php" in httpd.conf file in proxyA.

I tested with wrong file name (like: http://www.proxyA.com/path/1111.html),
1111.html is not in server B so I should get 404 error and ErrorDocument will redirect to senderror.php file but it is not working.

How do I catch this error and redirect to PHP file with requested URL from proxy server.

Thanks
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#4: Jul 4 '08

re: PHP and reverse proxy


ProxyErrorOverride might help you here (http://httpd.apache.org/docs/2.3/mod...yerroroverride).
Newbie
 
Join Date: Jul 2008
Posts: 28
#5: Jul 5 '08

re: PHP and reverse proxy


Thank you, pbmods. I have played with it and it is working.
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#6: Jul 5 '08

re: PHP and reverse proxy


Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime!
Reply