LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-21-2015, 05:03 AM   #1
setevoy
LQ Newbie
 
Registered: Oct 2013
Location: Kiev, UA
Distribution: CentOS
Posts: 10

Rep: Reputation: Disabled
Apache HTTP + Apache Tomcat + mod_rewrite


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 "http://domain.com".

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/www/www.domain.com
...

<VirtualHost *:443>
        ServerName www.domain.com
        DocumentRoot /var/www/www.domain.com

        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 http://domain.com/cloudlibrary/ui/somefile.js - 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 http://domain.com/cloudlibrary/ui/ - but all other "under" http://domain.com/cloudlibrary/) 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 http://domain.com/cloudlibrary/ui/somefile.js - 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.
 
Old 08-21-2015, 08:44 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You may try the following:
Code:
RewriteEngine On

RewriteCond %{REQUEST_URI} ^/cloudlibrary/ui/(.*)
RewriteCond %{DOCUMENT_ROOT}/test/1/%1 -f
RewriteRule ^/cloudlibrary/ui/(.*) /test/1/$1
RewriteRule  ^/cloudlibrary/ui/(.*) %{DOCUMENT_ROOT}/test/1/index.html
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How I can secure my servers (apache http and tomcat ) /Centos secrets88 Linux - Security 1 06-05-2015 06:11 AM
[SOLVED] HTTP Status 404 When try to connect tomcat from apache httpd sharonsreedh Linux - Newbie 2 06-20-2012 09:24 AM
[SOLVED] Apache HTTP Server and Tomcat rmknox Linux - Server 2 06-08-2011 12:09 PM
Apache HTTP - Tomcat and ModJK d0127810 Linux - Server 9 01-25-2009 12:27 PM
How to enable Apache mod_rewrite, after apache installed without this modue jCash Linux - Newbie 1 10-24-2006 10:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration