I have Apache httpd on port 80 and Morbo httpd server on port 3000 serving perl Mojolicious code. Morbo is available only from localhost.
Now I want to set up virtual host with proxy so that static files would be served by Apache and dynamic content would be serverd by Morbo.
This is my virtual host config:
<VirtualHost *:80>
ServerName mojo.myhost.com
DocumentRoot /opt/mojo/public
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^(.*) http://localhost:3000$1 [NS,P,L]
ProxyPassReverse / http://mojo.myhost.com
</VirtualHost>
The problem is that when I try to access http://mojo.myhost.com/
Apache subrequ is issued by Apache and request sent to Morbo is http://localhost:3000/error/noindex.html
and not http://localhost:3000/
.
Here is part of mod-rewrite log:
[rid#2b20905c58e0/initial] (2) init rewrite engine with requested uri /
[rid#2b20905c58e0/initial] (3) applying pattern '^(.*)' to uri '/'
[rid#2b20905c58e0/initial] (4) RewriteCond: input='/opt/mojo/public/' pattern='!-f' => matched
[rid#2b20905c58e0/initial] (4) RewriteCond: input='/opt/mojo/public/' pattern='!-d' => not-matched
[rid#2b20905c58e0/initial] (1) pass through /
[rid#2b20905cb910/subreq] (2) init rewrite engine with requested uri /index.php
[rid#2b20905cb910/subreq] (1) pass through /index.php
[rid#2b20905cd920/subreq] (2) init rewrite engine with requested uri /index.html
[rid#2b20905cd920/subreq] (1) pass through /index.html
[rid#2b20905cb910/subreq] (2) init rewrite engine with requested uri /index.html.var
[rid#2b20905cb910/subreq] (1) pass through /index.html.var
[rid#2b20905cd920/subreq] (2) init rewrite engine with requested uri /index.htm
[rid#2b20905cd920/subreq] (1) pass through /index.htm
[rid#2b20905caf40/initial/redir#1] (2) init rewrite engine with requested uri /error/noindex.html
[rid#2b20905caf40/initial/redir#1] (3) applying pattern '^(.*)' to uri '/error/noindex.html'
[rid#2b20905caf40/initial/redir#1] (4) RewriteCond: input='/opt/mojo/public/error/noindex.html' pattern='!-f' => matched
[rid#2b20905caf40/initial/redir#1] (4) RewriteCond: input='/opt/mojo/public/error/noindex.html' pattern='!-d' => matched
[rid#2b20905caf40/initial/redir#1] (2) rewrite '/error/noindex.html' -> 'http://localhost:3000/error/noindex.html'
[rid#2b20905caf40/initial/redir#1] (2) forcing proxy-throughput with http://localhost:3000/error/noindex.html
[rid#2b20905caf40/initial/redir#1] (1) go-ahead with proxy request proxy:http://localhost:3000/error/noindex.html [OK]
I added NS
flag to RewriteRule
but subreq still modifies the URL before it is passed to Morbo. How can I get Apache to pass / instead of /error/noindex.html to Morbo?
If both RewriteCond
are removed from virtualhost config then it works but static files are also serverd by Morbo (which I don't like so much).