Skip to content

Instantly share code, notes, and snippets.

@carpii carpii/haproxy.cfg Secret
Created Feb 23, 2017

Embed
What would you like to do?
global
maxconn 4096 # Max connections
nbproc 1 # cores on the machine
daemon
user haproxy
group haproxy
defaults
mode http
option http-server-close # reduce latency by closing connections but maintaining keep-alives
option forwardfor # X-Forwarded-For
maxconn 2000
retries 3
timeout connect 50000ms
timeout client 120000ms
timeout server 120000ms
log 127.0.0.1 local0 # can add an additional max, min level, e.g. 'notice'
option httplog
option dontlognull
frontend www-http
bind 192.168.1.79:80
reqadd X-Forwarded-Proto:\ http
default_backend www-backend
backend www-backend
server www-1 127.0.0.1:8000 check
http-request add-header X-TC-Client-IP %[src]
debug.log-request-handling = "enable"
server.modules = (
"mod_expire",
"mod_rewrite",
"mod_redirect",
"mod_access",
"mod_auth",
"mod_setenv",
"mod_fastcgi",
"mod_status",
"mod_compress",
"mod_magnet",
"mod_accesslog",
"mod_extforward" )
server.max-keep-alive-requests = 4
server.max-keep-alive-idle = 4
server.max-read-idle = 60
server.max-write-idle = 360
server.document-root = "/www/testing"
server.port = 8000
server.pid-file = "/var/run/lighttpd.pid"
server.errorlog = "/var/log/lighttpd/error.log"
server.tag = "lighttpd"
server.username = "lighttpd"
server.groupname = "lighttpd"
extforward.headers = ("X-Forwarded-For")
extforward.forwarder = ("127.0.0.1" => "trust")
index-file.names = ( "index.php", "index.html" )
accesslog.filename = "/var/log/lighttpd/lighttpd.log"
accesslog.format = "%{X-TC-CLIENT-IP}i [%{X-LIGHTTPD-UID}o] [\"%{X-FORWARDED-FOR}i\"] [%T] %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-REQUESTED-WITH}i\" \"%{X-Forwarded-Proto}i\" \"%{Host}i\""
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
$HTTP["scheme"] == "http" {
accesslog.filename = "/var/log/lighttpd/debug_access.log"
$HTTP["host"] =~ ".+" {
url.redirect = (".*" => "https://%0$0/foo1")
}
else {
url.redirect = (".*" => "https://msolo.carpnet.local$0/foo2")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.