使用ProxyPass时,我的Apache反向代理没有返回正确的URL

时间:2013-08-09 15:21:46

标签: apache2 reverse-proxy

我有以下配置,它始终将URL返回为“https:\ sysaid.external.comlogin.jsp”,“https://sysaid.external.com”和“login.jsp”之间没有“/”。

#REDIRECT for http://sysaid.external.com
<VirtualHost *:80>
        ServerName sysaid.external.com
        ProxyPreserveHost On
        Redirect / https://sysaid.external.com
</VirtualHost>

#https://sysaid.external.com
<VirtualHost *:443>
        ServerAdmin webmaster@external.com
        ServerName sysaid.external.com
        SSLEngine on
        SSLCertificateFile    /usr/local/etc/apache22/ssl/webmail.external.com.crt
        SSLCertificateKeyFile /usr/local/etc/apache22/ssl/webmail.external.com.key
        ProxyPreserveHost On
        ProxyPass / http://srv-01.internal.local:80/
        ProxyPassReverse / http://srv-01.internal.local:80/
        ProxyPassReverse / http://sysaid.external.com:80/
</VirtualHost>

虽然没有SSL重定向但这个工作正常......

#http://sysaid.external.com
<VirtualHost *:80>
    ServerAdmin webmaster@external.com
    ServerName sysaid.external.com
    ProxyRequests Off
    ProxyPreserveHost On
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass / http://srv-01.internal.local:80/
    ProxyPassReverse / http://srv-01.internal.local:80/
    <Location />
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>

我还有其他人,我使用SSL重定向,他们都没有问题。

从代理服务器从telnet到Web服务器的测试我得到以下结果:

root@core-rp-01:/home/user # telnet srv-01.internal.local 80
Trying 172.34.0.10...
Connected to srv-01.internal.local.
Escape character is '^]'.
GET / HTTP/1.1
Host: sysaid.external.com

HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=F5FA5C04242A51536916C688A23077F1; Path=/; HttpOnly
Location: http://sysaid.external.com/Login.jsp
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 0
Date: Fri, 09 Aug 2013 15:16:06 GMT

思想?

谢谢!

1 个答案:

答案 0 :(得分:0)

解决:

#REDIRECT for http://sysaid.external.com
<VirtualHost *:80>
        ServerName sysaid.external.com
        ProxyPreserveHost On
        Redirect / https://sysaid.external.com
</VirtualHost>

#https://sysaid.external.com
<VirtualHost *:443>
        ServerAdmin webmaster@external.com
        ServerName sysaid.external.com
        SSLEngine on
        SSLCertificateFile    /usr/local/etc/apache22/ssl/webmail.external.com.crt
        SSLCertificateKeyFile /usr/local/etc/apache22/ssl/webmail.external.com.key
        ProxyPreserveHost On
        ProxyPass / http://srv-01.internal.local/
        ProxyPassReverse / http://srv-01.internal.local/
        ProxyPassReverse / http://sysaid.external.com/
</VirtualHost>