0

I'm trying to get apache to route app.example.com to app.example.com/app where the application is running on tomcat. With the code below I keep getting infinite loop errors.

Httpd.conf

NameVirtualHost *:80
<VirtualHost *:80>
 ServerName app.example.com
 ServerAlias app.example.com
 <IfModule mod_rewrite.c>
    ProxyPass         /app  http://app.example.com:8080/app/
    ProxyPassReverse  /app  http://app.example.com:8080/app/
    ProxyPreserveHost off

    <Location "/app">
      Order allow,deny
      Allow from all
    </Location>

    RewriteCond %{HTTP_HOST} ^app\.example\.com$ [NC]
    RewriteRule ^(.*)$ http://app.example.com/app/ [L,PT]
    RewriteEngine On
  </IfModule>
</VirtualHost>

Tomcat server.xml snippet

<Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443"
           proxyPort="80" />
4

1 回答 1

0

尝试这个

NameVirtualHost *:80
<VirtualHost *:80>
 ServerName app.example.com
 ServerAlias app.example.com
 <IfModule mod_rewrite.c>
    ProxyRequests Off
    ProxyVia Off
    ProxyPreserveHost On

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    <Location "/app">
      Order allow,deny
      Allow from all
    </Location>
    ProxyPass / http://app.example.com:8080/app/
  </IfModule>
</VirtualHost>
于 2012-08-17T22:19:27.260 回答