Skip to content

Instantly share code, notes, and snippets.

@rodrigodev
Created August 15, 2017 18:42
Show Gist options
  • Save rodrigodev/dc07b92cdb0d6a7f5129568a33aa1cb4 to your computer and use it in GitHub Desktop.
Save rodrigodev/dc07b92cdb0d6a7f5129568a33aa1cb4 to your computer and use it in GitHub Desktop.
Haproxy subdomain redirect
frontend http-in
mode http
bind FRONTENDIP:80
default_backend nginx_server_1
acl nginx_1 hdr_end(host) -i www.xyz.com
acl nginx_2 hdr_end(host) -i abc.xyz.com
acl nginx_path path_beg /abc/
use_backend nginx_server_1 if nginx_1 !nginx_path
backend nginx_server_1
server nginx1 10.0.0.1:8080 maxconn 1000
backend nginx_server_2
server nginx2 10.0.0.2:8080 maxconn 1000
@realtebo
Copy link

Thank You for this gist.
Can I ask you how will be selected the second server?

@rodrigodev
Copy link
Author

rodrigodev commented Sep 10, 2018

HI @realtebo, this is for reference only, for more details you can look here:
https://serverfault.com/questions/325606/haproxy-subdomain-redirect
Where I got this config from...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment