mod rewrite - Using Apache HTTPD to proxy requests and when in error set status 200 and the error document -
i'm using apache httpd 2.4.12 proxy request remote server. if remote host returns error code such 502 need handle , return custom error page status of 200. workaround application issue doesn't handle non-200 errors , needs particular payload.
i can return custom error page status 502 (without rewriterule) or standard ok page status set 200. here's part of httpd.conf replicates latter:
<location /dm> proxypass http://url.of/dm/ proxypassreverse http://url.of/dm/ errordocument 502 /error/error.html </location> rewriteengine on rewritecond %{request_uri} /error/error.html rewriterule ^(.*)$ /error/error.html [r=200,l]
or there better alternatives apache httpd this? i'd use apache if possible because it's installed on system.
i had mod_lua installed on our apache instance fixed setting in httpd.conf:
<files *.lua> sethandler lua-script </files> <location /dm> proxypass http://url.of/dm/ proxypassreverse http://url.of/dm/ errordocument 502 /error/error.lua </location>
then created script /error/error.lua:
function handle(r) r.content_type = "text/html" -- set output text/html r:puts("my custom error payload") r.status = 200 return apache2.ok end
Comments
Post a Comment