Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Apache virtual hosting: how to delegate *all* requests to Tomcat/servlet?

843840Aug 26 2001 — edited Aug 28 2001
Allow me to repeat something I posted in news:alt.apache.configuration, as I do not know where else to ask for help... Hints for better places to ask these questions are appeciated!

I want to create a kind of filtering proxy. So, I have set up Apache to work with Tomcat 3.2.3 (mod_jk) and pass all requests of some virtual hosts to Tomcat, to have it handled by my filter servlet. It works great, except for two things:

-1-
If I have an index.html in Apache's htdocs, then calls to the virtual host are not always delegated to Tomcat. Like "my.virtual-host.blah" and "my.virtual-host.blah/non-common-name.html" are delegated to Tomcat, but "my.virtual-host.blah/index.html" (or in general: any document name that also happens to be known to the web server) is served by Apache itself.

-2-
I cannot prevent jsp files to be handled by the JSP thing in Tomcat (instead of calling my filter servlet), even although I do not explicitly map *.jsp. I am not including the Tomcat generated conf/mod_jk.conf-auto. And I removed the global Tomcat conf/web.xml. How does Tomcat still recognize the *.jsp files?

Any clues?

Some more details below. I feel stupid to bother you with this while I cannot provide you with all the details, but I forgot to send the Tomcat server.xml to my home address... I know I mapped the root to my filter servlet context (either mapped "" or "/"). I removed anything that seemed to refer to JSP files. I also defined virtual hosts (in server.xml), but removed them again it as it did not seem to have any effect. It all works fine, except for the problems above. At least for the index.html problem, I really think I missed something in the Apache server settings?

While compacting the details below I noted something. I cannot test it now, but should I have uncommented "BindAddress"? Ooops, I also just read "You may use the command line option '-S' to verify your virtual host configuration". Cannot test that now either, but all comments appreciated!

Thanks a lot,
Arjan.

++ Some lines from Apache's http.conf
#BindAddress *
LoadModule proxy_module modules/mod_proxy.so
LoadModule rewrite_module modules/mod_rewrite.so
ServerName myserver

DocumentRoot "U:\projects\myFilter\deploy"
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory "D:/Program Files/Apache Group/Apache/htdocs">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<IfModule mod_rewrite.c>
    RewriteEngine  on
    RewriteLog c:/rewrite.log
    RewriteLogLevel 9
</IfModule>

<IfModule mod_proxy.c>
    ProxyRequests On
    <Directory proxy:*>
        Order deny,allow
        Deny from all
# Just for testing:
        Allow from all
    </Directory>
#    ProxyRemote ...
#    ProxyPass ...
#    ProxyPassReverse  ...
#    ProxyVia On
#    CacheRoot "D:/Program Files/Apache Group/Apache/proxy"
#    CacheSize 5
#    CacheGcInterval 4
#    CacheMaxExpire 24
#    CacheLastModifiedFactor 0.1
#    CacheDefaultExpire 1
#    NoCache a_domain.com another_domain.edu joes.garage_sale.com
</IfModule>

NameVirtualHost *

# See http://jakarta.apache.org/tomcat/tomcat-3.2-doc/mod_jk-howto.html
LoadModule jk_module modules/mod_jk.dll
JkWorkersFile "D:/jakarta-tomcat-3.2.3/conf/workers.properties"
JkLogFile "D:/jakarta-tomcat-3.2.3/logs/mod_jk.log"

# Requests for www.my-virtual-xx.com should pass through my
# own proxy servlet thing. However, no need to have this servlet
# handle images -- so we can have them served directly by the
# original server (microsoft and netscape are just examples...)

<VirtualHost *>
  ServerName www.my-virtual-microsoft.com

  # Have images served directly. Works fine.
  # In the search regex, (?: ) is not supported, nor is (?i: ). In the
  # substitution part, $& (last match) seems not allowed.
  RewriteRule (.*\.(gif|jpeg|jpg|png|bmp))$ http://www.microsoft.com$1 [P]

  # All others through our servlet
  JkMount /* ajp13
</VirtualHost>

<VirtualHost *>
  ServerName www.my-virtual-netscape.com
  RewriteRule (.*\.(gif|jpeg|jpg|png|bmp))$ http://www.netscape.com$1 [P]
  JkMount /* ajp13
</VirtualHost>
++ Some lines from Tomcat's web.xml
<web-app>
  <servlet>
    <servlet-name>myFilter</servlet-name>
    <servlet-class>com.some.myFilterServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>myFilter</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 25 2001
Added on Aug 26 2001
2 comments
322 views