AJP Proxy settigs with mod_rewrite

2.8k views Asked by At

I have a problem with AJP proxy settings.

Versions of SW
Oracle Linux Server 6.5, Apache 2.2.15, Apache Tomcat 7.0.29, tomcat-connectors-1.2.37-src.

Expected behaviour
With slash at the end of URL
http:/@/name.company.local/application/ --> http:/@/name.company.local:8080/application/
It works => OK

Without slash at the end of URL
http:/@/name.company.local/application -> http:/@/name.company.local:8080/application
It does NOT work => K.O.

With path after app name
http:/@/name.company.local/some/path -> http:/@/name.company.local:8080/application/some/path
It does NOT work => K.O.

Apache Log file (var/log/httpd/name.company.local-error_log)

[Fri Dec 13 10:48:33 2013] [error] [client 10.0.100.26] File does not exist: /var/www/name.company.local/application
[Fri Dec 13 10:48:33 2013] [error] [client 10.0.100.26] File does not exist: /var/www/name.company.local/application

AJP proxy settings (/etc/httpd/conf.d/ajp.conf)

ProxyRequests Off
<Proxy *>
  Order deny,allow
  Deny from all
  Allow from localhost
</Proxy>
ProxyPass /application ajp://localhost:8009/application
ProxyPassReverse /application ajp://localhost:8009/application

Apache settings (/etc/httpd/conf/httpd)

NameVirtualHost *:80
NameVirtualHost *:443
ServerName name.company.local

<VirtualHost *:80>
   ServerAdmin [email protected]
   DocumentRoot /var/www/name.company.local
   ServerName name.company.local
   ServerAlias application

   RewriteEngine On
   RewriteLog "/var/log/httpd/rewrite.log"
   RewriteLogLevel 9
   RewriteCond %{HTTP_HOST} !.local$
   RewriteRule ^/(.*)$ http:/@/name.company.local/$1 [R=301]
   RewriteCond %{REQUEST_URI} !^/application/
   RewriteRule ^/(.*)$ /application/$1
   LogFormat "%h %l %u %t \"%r\" %>s %b \"%{User-Agent}i\"" appspecial
   ErrorLog logs/name.company.local-error_log
   CustomLog logs/name.company.local-access_log appspecial
</VirtualHost>

Can you tell me, what is wrong? Or how can I debug it?

With regards

Nautil

P.S. Due to low reputation at Stack Overflow (I'm a newbie) I could not use more than 2 links, therefore I had to replace valid HTTP protocol prefix with http:/@/.

1

There are 1 answers

0
nautil2 On

I have solved Without slash at the end of URL problem by change of rewrite rule:
RewriteCond %{REQUEST_URI} !^/application
RewriteRule ^/(.*)$ /application/$1

I have also solved With path after app name problem, again with modification of rewrite rule: RewriteCond %{REQUEST_URI} !^/application
RewriteRule ^/(.*)$ http://name.company.local/application/$1