【发布时间】:2015-05-07 18:16:56
【问题描述】:
我在 haproxy 1.5 后面的 ubuntu 12.04 上使用 apache 2.2。我的 haproxy 正在侦听端口 80,而 apache 正在侦听端口 8000。我想做的是,我想将 haproxy 上带有路径“/test”的任何请求转发到我的 apache。
我有一个托管在“/var/www/test”中的 wordpress 应用程序。
我面临的问题是,如果我尝试使用 http://www.example.com/test 访问测试应用程序,apache 会将其重定向到 http://www.example.com:8000/test/ 。知道为什么会这样吗?我错过了什么?
这里是配置:
ports.conf:
NameVirtualHost *:8000
Listen 8000
<IfModule mod_ssl.c>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
网站可用/默认:
<VirtualHost *:8000>
ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
haproxy.cfg:
frontend http-in
bind *:80
acl is_test path_beg /test
use_backend test_backend if is_test
backend test_backend
balance roundrobin
option forwardfor
server Local localhost:8000 check
当我将它登录到 index.php 时,我发现 $_SERVER['HTTP_X_FORWARDED_HOST'] 是空的。知道为什么会这样。
【问题讨论】:
标签: wordpress apache load-balancing haproxy