Skip to content

Instantly share code, notes, and snippets.

@DusteDdk
Created January 12, 2020 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DusteDdk/3bda6534324f5f98bc68827d81577877 to your computer and use it in GitHub Desktop.
Save DusteDdk/3bda6534324f5f98bc68827d81577877 to your computer and use it in GitHub Desktop.
# Toy example, ha-proxy reversing traffic to two backend servers based on path
# Has url rewriting and header modification
global
debug # uncomment to enable debug mode for HAProxy
defaults
mode http # enable http mode which gives us layer 7 filtering
timeout connect 5000ms # max time to wait for a connection attempt to a server to succeed
timeout client 50000ms # max inactivity time on the client side
timeout server 50000ms # max inactivity time on the server side
backend mainSite
http-request set-header Host dusted.dk
server main dusted.dk
backend recipeSite
http-request set-path %[url,regsub(^/vafler/*,/,)] # anything going to this backend needs the URL rewritten to leave out that
http-request set-header Host vafler.dk
server vafler vafler.dk
frontend http
bind :80
default_backend mainSite
# /vafler lives on a different server
acl vaflerPath path_beg /vafler
use_backend recipeSite if vaflerPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment