Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache HTTP + Apache Tomcat + mod_rewrite

Status
Not open for further replies.

setevoy

Programmer
Aug 21, 2015
1
0
0
UA
Hi.

I haven't work with Apache HTTP for years, and faced with one task, which little bit confused me.

We have Apache HTTP on front and Apache Tomcat - on back end.

Next, we have some domain, let's say "
Main application works under Tomcat via AJP in httpd:

Code:
        ProxyPass /cloudlibrary ajp://localhost:8009/cloudlibrary
        ProxyPassReverse /cloudlibrary ajp://localhost:8009/cloudlibrary

Here is my current configuration:

Code:
...
DocumentRoot /var/[URL unfurl="true"]www/www.domain.com[/URL]
...

<VirtualHost *:443>
        ServerName [URL unfurl="true"]www.domain.com[/URL]
        DocumentRoot /var/[URL unfurl="true"]www/www.domain.com[/URL]

        RedirectMatch ^/$ /cloudlibrary/

        RewriteCond %{REQUEST_URI} /cloudlibrary/ui
        RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -f
        RewriteRule ^.*cloudlibrary(.*) %{DOCUMENT_ROOT}/test/1/$1 [L]

        RewriteCond %{REQUEST_URI} /cloudlibrary/ui
        RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
        RewriteRule ^.*cloudlibrary(.*) %{DOCUMENT_ROOT}/test/1/index.html [L]

        # Cloud Library
        #ProxyPass /cloudlibrary ajp://localhost:8009/cloudlibrary
        #ProxyPassReverse /cloudlibrary ajp://localhost:8009/cloudlibrary


        <Location /cloudlibrary>
                Header set Access-Control-Allow-Origin "*"
                Require all granted
        </Location>

What I'm trying to do:

if Apache get URL to - it must:

1) check if file exist on file system in %{DOCUMENT_ROOT}/test/1/somefile.js directory, if so - return it;
2) if file not found - return %{DOCUMENT_ROOT}/test/1/index.html;

All other requests (not - but all other "under" must be redirected to Tomcat.

Of course - my current setup doesn't work :)

I disabled Tomcat Proxy for now, and if I'm trying to open URL - I have 404, instead of file %{DOCUMENT_ROOT}/test/1/somefile.js or %{DOCUMENT_ROOT}/test/1/index.html.

Could anybody please help with this Apache HTTP configuration?

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top