Docs ModProxyCore » History » Revision 13
Revision 12 (jakabosky, 2006-12-18 03:10) → Revision 13/51 (hoffie, 2006-12-18 19:06)
{{{ #!rst =================== the Proxy Interface =================== ---------------------- Module: mod_proxy_core ---------------------- .. contents:: Table of Contents Description =========== ... Options ======= lighttpd provides the Proxy support via the proxy-module (mod_proxy_core) which provides the following options in the config-file: proxy-core.balancer might be one of 'round-robin', 'sqf' or 'carp'. proxy-core.protocol might be one of 'http', 'fastcgi' or 'scgi'. Make sure you load the backend modules (see mod_proxy_backend_http/mod_proxy_backend_fastcgi/mod_proxy_backend_scgi/mod_proxy_backend_ajp13) proxy-core.backends tell the module where to send Proxy requests to. It is a list of hostname/ip address/unix-domain socket proxy-core.max-pool-size max size for pool of connections to backends. proxy-core.check-local enable checking for url file in local document-root. Enable this for php proxy-core.allow-x-sendfile enables use of "X-Sendfile/X-LIGHTTPD-Sendfile/X-LIGHTTPD-send-tempfile" headers. proxy-core.allow-x-rewrite proxy-core.rewrite-request rewrite request headers or request uri. proxy-core.rewrite-response rewrite response headers. Example: ======== Using lighttpd + mod_proxy_core in front of 8 Squids which handle the caching of dynamic content for you. All requests for the host www.example.org should be forwarded to the proxy. All proxies listen on port 80 for requests. :: server.modules += ( "mod_proxy_backend_http" ) $HTTP["host"] == "www.example.org" { proxy-core.protocol = "http" proxy-core.balancer = "carp" proxy-core.backends = ( "10.0.0.10", "10.0.0.11", "10.0.0.12", "10.0.0.13", "10.0.0.14", "10.0.0.15", "10.0.0.16", "10.0.0.17" ) } If one of the hosts goes down the all requests for this one server are moved equally to the other servers. If you want to know more about the algorithm used here google for 'Microsoft CARP'. for php using unix-domain socket "/tmp/php-fastcgi.sock" :: server.modules += ( "mod_proxy_backend_fastcgi" ) $HTTP["url"] =~ "\.php$" { proxy-core.balancer = "round-robin" proxy-core.protocol = "fastcgi" proxy-core.check-local = "enable" proxy-core.allow-x-sendfile = "enable" proxy-core.backends = ( "unix:/tmp/php-fastcgi.sock" ) proxy-core.max-pool-size = 16 } for SCGI :: server.modules += ( "mod_proxy_backend_scgi" ) $HTTP["url"] =~ "\.scgi$" { proxy-core.balancer = "round-robin" proxy-core.protocol = "scgi" proxy-core.check-local = "enable" proxy-core.allow-x-sendfile = "enable" proxy-core.backends = ( "127.0.0.1:9090" ) proxy-core.max-pool-size = 16 } for http-proxy with host and file-extension conditionals :: server.modules += ( "mod_proxy_backend_http" ) $HTTP["host"] == "www.example.org" { proxy-core.protocol = "http" proxy-core.balancer = "carp" $HTTP["url"] =~ "\.php$" { proxy-core.backends = ( "10.0.0.10:80" ) } else $HTTP["url"] =~ "\.scgi$" { proxy-core.backends = ( "10.0.0.11:80" "10.0.0.10:80" ) } } Reverse-Proxying :: server.modules += ( "mod_proxy_backend_http" ) $HTTP["url"] =~ "^/proxyme(/|$)" { proxy-core.balancer = "round-robin" proxy-core.protocol = "http" proxy-core.backends = ( "en.wikipedia.org" ) proxy-core.rewrite-response = ( "Location" => ( "^http://en.wikipedia.org/(.*)" => "http://127.0.0.1:1025/proxyme/$1" ), ) proxy-core.rewrite-request = ( "_uri" => ( "^/proxyme/?(.*)" => "/$1" ), "Host" => ( ".*" => "en.wikipedia.org" ), ) } for proxying to Tomcat using AJP13 protocol :: server.modules += ( "mod_proxy_backend_ajp13" ) $HTTP["url"] =~ "^/tomcat/" { proxy-core.balancer = "round-robin" proxy-core.protocol = "ajp13" proxy-core.backends = ( "localhost:8009" ) proxy-core.max-pool-size = 16 } }}}