I’m trying to redirect user to different server based on domain hostname. It seems so easy, but I have spent a week and haven’t found a solution. This is my /etc/haproxy/haproxy.cfg
.
frontend t-proxy
bind 0.0.0.0:80
mode http
acl url_ex hdr(host) -i my.domain.xyz
use_backend ex if url_ex
backend ex
mode http
balance roundrobin
server vps12 (IP_ADDRESS_A):80 check
server vps3 (IP_ADDRESS_B):80 backup
This is virtualhost on vps12
and vps3
(both have same copies).
<VirtualHost *:443>
ServerAdmin user@mail.net
ServerName my.domain.xyz
DocumentRoot /var/www/domain
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
SSLEngine on
SSLCertificateFile /opt/acme-cert/my.domain.xyz/cert.pem
SSLCertificateKeyFile /opt/acme-cert/my.domain.xyz/site.key
SSLCertificateChainFile /opt/acme-cert/my.domain.xyz/fullchain.cer
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName my.domain.xyz
Redirect permanent / https://my.domain.xyz/
</VirtualHost>
But when I type my.domain.xyz
on browser, it took so long to load and I’m presented with this.
Checking haproxy.log
yield this, I’m not sure if its useful.
Jun 11 08:30:44 vps-proxy haproxy[7511]: (CLIENT_IP):34498 [11/Jun/2022:08:30:44.594] t-proxy ex/vps12 0/0/1/1/2 301 423 - - ---- 1/1/0/0/0 0/0 "GET / HTTP/1.1"
Anyone can help troubleshooting this problem ? I feel like I’m missing the obvious here.
1 post - 1 participant