Skip to content

Instantly share code, notes, and snippets.

@michimau
Last active September 24, 2021 10:22
Show Gist options
  • Select an option

  • Save michimau/80da3b60a6309f56520570cd025fd699 to your computer and use it in GitHub Desktop.

Select an option

Save michimau/80da3b60a6309f56520570cd025fd699 to your computer and use it in GitHub Desktop.
haproxy.cfg
defaults
timeout connect 5s
timeout client 1m
timeout server 1m
frontend http_front
bind *:80
mode http
acl app1 path_beg -i /nginx
acl app2 path_beg -i /apache
default_backend http_back
use_backend srvs_nginx if app1
use_backend srvs_apache if app2
######redirect mode######
#backend srvs_nginx
# mode http
# option forwardfor
# redirect location http://localhost:82
#
#backend srvs_apache
# mode http
# option forwardfor
# redirect location http://localhost:81
#
######proxy mode######
backend srvs_nginx
mode http
option forwardfor
http-request set-uri %[url,regsub(^/nginx,/,)]
#if { path_beg /nginx }
server server1 nginx:80
backend srvs_apache
mode http
option forwardfor
http-request set-uri %[url,regsub(^/apache,/,)]
#if { path_beg /apache }
server server2 apache:80
backend http_back
#balance roundrobin
balance leastconn
mode http
option forwardfor
server server1 nginx:80
server server2 apache:80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment