具有代理反向的HTTPS重定向URL

时间:2012-04-30 14:05:55

标签: apache redirect ssl reverse-proxy

我在使用此vhost配置的tomcat webapps前面有一个apache代理反向

我需要将http或https基本网址重定向到这样的https统计网址:

http:/ /xxx.domaine.tld重定向到https:/ /xxx.domaine.tld/JOrgInet/JORGServlet?FNAME=jorgentry.htt&P=LOCATION~FRA;DHTML~1;APPLI~ORGCHART;

https:/ /xxx.domaine.tld重定向到https:/ /xxx.domaine.tld/JOrgInet/JORGServlet? FNAME=jorgentry.htt&P=LOCATION~FRA;DHTML~1;APPLI~ORGCHART;

这是vhost配置文件

<Virtualhost *:80>
    ServerName org.domaine.tld
    Redirect / https://org.domaine.tld/JOrgInet/JORGServlet?FNAME=jorgentry.htt&P=LOCATION~FRA;DHTML~1;APPLI~ORGCHART;
</Virtualhost>

<VirtualHost *:443>

   ServerName org.domaine.tld:443
   ErrorLog /var/log/apache2/domaine.tld.error.log
   CustomLog /var/log/apache2/domaine.tld.log combined

   LogLevel warn

   SSLProxyEngine on
   SSLCACertificateFile /etc/apache2/certs/gs_root.pem
   SSLCertificateChainFile /etc/apache2/certs/intermediate.pem
   SSLCertificateFile /etc/apache2/certs/gscert.pem
   SSLCertificateKeyFile /etc/apache2/certs/gscert.key

   <Location />
        AuthType Basic
        AuthBasicProvider ldap
        AuthName "Login LDAP SERVER"
        AuthLDAPURL "ldap://xxx.xxx.xxx.xxx:389/o=XXXXXXXXXXX?uid"
        Require valid-user
        AuthLDAPRemoteUserAttribute uid
        RewriteEngine On
        RewriteCond %{LA-U:REMOTE_USER} (.+)
        RewriteRule .* - [E=RU:%1]       
        RequestHeader set REMOTE_USER %{RU}e
   </Location>

   <IfModule mod_cache.c>
      <IfModule mod_disk_cache.c>
         CacheDefaultExpire 3600
         CacheEnable disk /
         CacheRoot "/var/cache/apache2"
         CacheDirLevels 2
         CacheDirLength 1
         CacheMaxFileSize 1000000
         CacheMinFileSize 1
         CacheIgnoreCacheControl On
         CacheIgnoreNoLastMod On
         CacheIgnoreQueryString Off
         CacheIgnoreHeaders None
         CacheLastModifiedFactor 0.1
         CacheDefaultExpire 3600
         CacheMaxExpire 86400
         CacheStoreNoStore On
         CacheStorePrivate On
      </IfModule>
   </IfModule>

   ProxyPass / ajp://xxx.xxx.xxx.xxx:8009/
   ProxyPassReverse / https://org.domaine.tld/

</VirtualHost>

当我在http中访问基本URL时没关系但是当我使用https基本URL访问时如何重定向到复杂的URL ...

提前致谢。

EB

1 个答案:

答案 0 :(得分:0)

您可以使用mod_rewrite做您想做的事。在您的SSL VirtuaLHost配置中,尝试以下内容:

RewriteEngine On
RewriteRule ^/$ https://%{SERVER_NAME}/JOrgInet/JORGServlet?FNAME=jorgentry.htt&P=LOCATION~FRA;DHTML~1;APPLI~ORGCHART; [R]

这仅匹配/的请求,并通过客户端重定向重定向它们。

有关更多信息,请查看Apache URL rewriting guide