问题描述
说明:
我们有两台apache服务器,其中一台在haproxy之后。我们的新服务器位于haproxy盒后面,旧服务器位于另一个网络上。我将创建一个Apache重写规则,以将该oldsite.com/some/thing指向新的haproxy框(如下所示)。这将重定向到newsite /一些/其他东西。
DESCRIPTION:We have two apache servers and one is behind haproxy. Our NEW server is behind the haproxy box, the OLD one is on a different network. I am going to create an apache rewrite rule to point this oldsite.com/some/thing to the new haproxy box (as seen below). This will redirect to newsite/some/other thing.
问题:
是否可以使用户透明?我希望用户只看到oldsite.com/some/thing而看不到newsite / some / other / thing?用haproxy可以做到吗?我对haproxy了解得很少,但了解得很少。在此先感谢您的时间。
QUESTION:Is it possible to make this transparent to the user? I would like the user to only see oldsite.com/some/thing and not newsite/some/other/thing ? Is this achieveable with haproxy? I know a little about haproxy but not a lot. Thanks in advance for your time. much appreciated.
推荐答案
基于@Panama Jack的技巧,我创建了一个基本测试,认为对我有用。这只是一个粗略的配置,需要保护措施等才能正常工作。这是Apache 2.4(amazon AMI)。如上所示,我想使第二台服务器对用户透明。
Based on the tip from @Panama Jack, I created a basic test which I think will work for me. This is just the rough config and requires protections and so forth to get working fully. This is apache 2.4 (amazon AMI). As you see above, I am wanting to make the second server transparent to the user.
此示例(快速而又肮脏)的安装程序执行以下操作:
This example (quick and dirty) setup does the following:
- login.HOST.info = login.DESTINATION.info
- (用户从未看到过login.DESTINATION.info网址该页面实际存在的位置)
服务器处理请求:
<VirtualHost *:80>
ServerAdmin admin@localhost
ServerName login.HOST.info
ServerAlias www.login.HOST.info
ErrorLog logs/login-error_log
CustomLog logs/login-access_log common
RewriteEngine On
RequestHeader add X-SSL off
RewriteRule ^/(.*) http://login.DESTINATION.info/$1 [P,L]
</VirtualHost>
最终服务器处理请求:
<VirtualHost *:80>
ServerName login.DESTINATION.info
ServerAdmin [email protected]
DocumentRoot /var/www/deal/site/locator/whatever/
RemoteIPHeader X-Forwarder-For # allows the host to remain
RemoteIPInternalProxy XXXX.0.0.0/8 # ip of other machine
</VirtualHost>
这篇关于从现有域重定向到新域(Apache / haproxy)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!