Mobile app version of vmapp.org
Login or Join
Nickens628

: Haproxy + Apache + virtual hosts -> wrong host is displayed On CentOS 7.2.1511 Linux I have installed haproxy-1.5.14-3.el7.x86_64 and httpd-2.4.6-40.el7.centos.1.x86_64 packages. The /etc/haproxy/haproxy.cfg

@Nickens628

Posted in: #Apache #Apache2 #Dns #Haproxy #Vhost

On CentOS 7.2.1511 Linux I have installed
haproxy-1.5.14-3.el7.x86_64 and
httpd-2.4.6-40.el7.centos.1.x86_64 packages.

The /etc/haproxy/haproxy.cfg binds HAProxy to
ports 80 and 443 and accepts HTTPS to slova.de:

defaults
mode http
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
....
frontend public
bind 144.76.184.151:80
bind 144.76.184.151:443 ssl crt /etc/pki/tls/certs/slova.de.pem
reqidel ^X-Forwarded-Proto:
reqidel ^X-Forwarded-For:
reqadd X-Forwarded-Proto: https if { ssl_fc }
default_backend apache

backend apache
server domain 127.0.0.1:8080


The /etc/httpd/conf/httpd.conf binds Apache
to port 8080 and serves few Wordpress sites:

Listen 127.0.0.1:8080
ServerName 144.76.184.151

<VirtualHost 127.0.0.1:8080>
DocumentRoot /var/www/html/afarber.de
ServerName afarber.de
ErrorLog logs/afarber.de/error_log
CustomLog logs/afarber.de/access_log common
</VirtualHost>

<VirtualHost 127.0.0.1:8080>
DocumentRoot /var/www/html/ruhrgebietsingle.de
ServerName ruhrgebietsingle.de
ErrorLog logs/ruhrgebietsingle.de/error_log
CustomLog logs/ruhrgebietsingle.de/access_log common
</VirtualHost>

<VirtualHost 127.0.0.1:8080>
DocumentRoot /var/www/html/bukvy.de
ServerName bukvy.de
ErrorLog logs/bukvy.de/error_log
CustomLog logs/bukvy.de/access_log common
</VirtualHost>

<VirtualHost 127.0.0.1:8080>
DocumentRoot /var/www/html/slova.de
ServerName slova.de
ErrorLog logs/slova.de/error_log
CustomLog logs/slova.de/access_log common
</VirtualHost>


When I open slova.de or slova.de they work fine.

But when I try to open the above URLs
with prepended, the browser displays ruhrgebietsingle.de (the 2nd site out of 4) instead.

Why does it happen? I just can not figure it out.

What tool would help here to debug?

In debug console of Chrome browser I see 301 Moved Permanently - but who and why sends it?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Nickens628

1 Comments

Sorted by latest first Latest Oldest Best

 

@Deb1703797

Ok, I had to add ServerAlias for each server, didn't think of it because before I had a mod_rewrite rule to remove the prefix...

<VirtualHost 127.0.0.1:8080>
DocumentRoot /var/www/html/afarber.de
ServerName afarber.de
ServerAlias *.afarber.de
ErrorLog logs/afarber.de/error_log
CustomLog logs/afarber.de/access_log common
</VirtualHost>

<VirtualHost 127.0.0.1:8080>
DocumentRoot /var/www/html/ruhrgebietsingle.de
ServerName ruhrgebietsingle.de
ServerAlias *.ruhrgebietsingle.de
ErrorLog logs/ruhrgebietsingle.de/error_log
CustomLog logs/ruhrgebietsingle.de/access_log common
</VirtualHost>

<VirtualHost 127.0.0.1:8080>
DocumentRoot /var/www/html/bukvy.de
ServerName bukvy.de
ServerAlias *.bukvy.de
ErrorLog logs/bukvy.de/error_log
CustomLog logs/bukvy.de/access_log common
</VirtualHost>

<VirtualHost 127.0.0.1:8080>
DocumentRoot /var/www/html/slova.de
ServerName slova.de
ServerAlias *.slova.de
ErrorLog logs/slova.de/error_log
CustomLog logs/slova.de/access_log common
</VirtualHost>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme