0
votes

I need an example HAProxy config to do the following:

Server1 = 192.168.0.177 ( I did not give the servers names - only IP's)

On Server1, I run HAproxy as well as Apache.

Apache on Server1 is setup to listen on port 8080 now, and has two Virtual Hosts correctly setup for two sub-domains - each serving its own website content. Sub-domain 1 = s.mydomain.com Sub-domain 2 = x.mydomain.com

I have a second server running on 192.168.0.233.

I want to setup HAProxy to listen to s.mydomain.com and then forward it to Apache on the same server ( 192.168.0.177), x.mydomain.com and forward it to Apache on the same server (192.168.0.177) and y.mydomain.com and forward traffic to the second server (192.168.0.233).

I do not need any load balancing at this point, just routing/forwarding as described above.

1

1 Answers

1
votes

Here you go,

global
  #debug

defaults
  mode http
  option httpclose
  timeout connect 5000ms
  timeout client 50000ms
  timeout server 50000ms

backend same_server
  server same_server 127.0.0.1:8001

backend second_server
  server second_server 192.168.0.233:80

frontend app *:80
  acl sub_y hdr(host) -i y.mydomain.com
  use_backend second_server if sub_y
  default_backend same_server