我已经在我的应用服务器中安装了Apache httpd 2.2.15。当我点击https://ip_address:9002/xxstorefront/xx/en/USD/login时,需要获得登录页面(https://dev.xxyy.com/login)。我已经为我的域安装了SSL证书,并在重定向规则下进行了设置。
ProxyPass /login http://localhost:9001/xxstorefront/xx/en/USD/login
ProxyPassReverse /login http://localhost:9001/xxstorefront/xx/en/USD/login
ProxyPass /login https://localhost:9002/xxstorefront/xx/en/USD/login
ProxyPassReverse /login https://localhost:9002/xxstorefront/xx/en/USD/login
RewriteEngine On
RewriteRule ^(.*)/login http://%{ip_address:9001}$1/{xxstorefront/xx/en/USD/login}$2 [L,R]
当我击中https://dev.xxyy.com/login时,出现错误提示,
Not Found
The requested URL /login was not found on this server.
Apache/2.2.15 (CentOS) Server at dev.xxyy.com Port 443
点击https://dev.xxyy.com时,我会得到apache默认主页。
请指导我如何设置重定向规则。
答案 0 :(得分:1)
您的配置无效。这两行:
ProxyPass /login https://localhost:9002/xxstorefront/xx/en/USD/login
ProxyPassReverse /login https://localhost:9002/xxstorefront/xx/en/USD/login
覆盖这两个:
ProxyPass /login http://localhost:9001/xxstorefront/xx/en/USD/login
ProxyPassReverse /login http://localhost:9001/xxstorefront/xx/en/USD/login
rewite机制可能根本不起作用:
RewriteEngine On
RewriteRule ^(.*)/login http://%{ip_address:9001}$1/{xxstorefront/xx/en/USD/login}$2 [L,R]
我认为这种配置应该可以解决您的问题:
<VirtualHost *:80>
ServerName dev.xxyy.com
ProxyPreserveHost On
ProxyPass / http://localhost:9001/xxstorefront/xx/en/USD/
ProxyPassReverse / http://localhost:9001/xxstorefront/xx/en/USD/
</VirtualHost>
<VirtualHost *:443>
ServerName dev.xxyy.com
SSLEngine on
// other SSL directives
ProxyPreserveHost On
ProxyPass / https://localhost:9002/xxstorefront/xx/en/USD/
ProxyPassReverse / https://localhost:9002/xxstorefront/xx/en/USD/
</VirtualHost>
它定义了两个虚拟主机,它们充当代理并将所有请求映射到xxstorefront/xx/en/USD/...
:
http://dev.xxyy.com/(.*) → http://localhost:9001/xxstorefront/xx/en/USD/(.*)
https://dev.xxyy.com/(.*) → https://localhost:9002/xxstorefront/xx/en/USD/(.*)