I have a weird problem when I have two separate urls pointing to the same Rails application
- staging.abcxyz.com
- staging.abcttt.com
My installation starts apache with the passenger. It is important to note here that both URLs point to the same Rails application in the document root directory directory and are simply served by different URLs inside.
Problem
When I try to access staging.abcxyz.com, it works and the application is displayed and everything works as expected.
When I try to access staging.abcttt.com, apache returns the forbidden 403 code.
Apache configuration
This is an apache url configuration that doesn't work for me. It is exactly the same as the one that works, expecting changes to the urls.
<VirtualHost *:80>
ServerName staging.abcttt.com
ServerAlias www.staging.abcttt.com
DocumentRoot /srv/abcxyz/current/public/
<Directory /srv/abcxyz/current/public/>
Order allow,deny
Allow from all
Options FollowSymLinks
AllowOverride None
</Directory>
RewriteEngine on
RewriteRule ^/$ /s/home [P]
RailsAutoDetect On
RackEnv staging
RailsEnv staging
RailsSpawnMethod smart
PassengerAppGroupName abcxyz
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript application/javascript application/json
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
RequestHeader set X-Request-Start "%t"
RewriteEngine On
ErrorDocument 503 /system/maintenance.html
RewriteCond %{REQUEST_URI} !\.(css|jpg|png|gif)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [R=503,L]
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}/index.html -f
RewriteRule ^/?$ /index.html [QSA,L]
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f
RewriteRule ^(.*)$ $1 [QSA,L]
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.html -f
RewriteRule ^(.*)$ $1.html [QSA,L]
</VirtualHost>
Questions
I donβt understand why this is a permission issue, since staging.abcxyz.com can already access the folder. I missed something because both of them are served from the same directory.
Could this be something called PassengerAppGroupName, but I'm not particularly worried that a separate worker sends a response to a specific request
I would really appreciate any help with this. Thanks.
Update
I notice that if I use the R [redirect] flag instead of P [proxy], the application works and redirects to the correct URL, but I want to be an internal redirect that does not affect the browser.