4

I have a strange problem where I have two separate urls pointing to the same Rails application

  1. staging.abcxyz.com
  2. staging.abcttt.com

My setup runs apache with passenger. The important thing to note here is that both urls point to the same Rails application in the Document Root directory and are just served by a different urls internally.

Problem

When i try to access staging.abcxyz.com it works and the application is rendered and everything works as expected.

When i try to access staging.abcttt.com apache returns a 403 forbidden.

Apache Config

This is apache configuration of the url that doesn't work for me. Its exactly the same as the one that works expect for changes in the urls.


&ltVirtualHost *:80&gt
  ServerName staging.abcttt.com

  ServerAlias www.staging.abcttt.com
  DocumentRoot /srv/abcxyz/current/public/
  &ltDirectory /srv/abcxyz/current/public/&gt
      Order allow,deny
    Allow from all
  Options FollowSymLinks
    AllowOverride None

  &lt/Directory&gt
 RewriteEngine on
 RewriteRule ^/$ /s/home [P]
 RailsAutoDetect On
  RackEnv staging
  RailsEnv staging
  RailsSpawnMethod smart


  ## PassengerAppGroupName
  #
  # By default, Passenger groups applcations by the the path they are served out of,
  # ie /srv/yourapp/current.
  #
  # At times, it may be useful be serving the same app from multiple vhosts, but have
  # them be have different workers. For example, you may have a /ping URL that needs to
  # respond quickly, without being affected by the rest of the app. In this case, you can:
  #
  #  * create a new vhost pointing at the same app
  #  * set PassengerAppGroupName to ping
  #  * configure a proxy to forward /ping to the new vhost


  PassengerAppGroupName abcxyz

 # Deflate
  &ltIfModule mod_deflate.c&gt
    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
  &lt/IfModule&gt

  RequestHeader set X-Request-Start "%t"

  RewriteEngine On

  # Check for maintenance file and redirect all requests
  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]


  # Rewrite index to check for static
  RewriteCond  %{THE_REQUEST} ^(GET|HEAD)
  RewriteCond  %{DOCUMENT_ROOT}/index.html -f
  RewriteRule  ^/?$ /index.html [QSA,L]

  # Rewrite to check for Rails non-html cached pages (i.e. xml, json, atom, etc)
  RewriteCond  %{THE_REQUEST} ^(GET|HEAD)
  RewriteCond  %{DOCUMENT_ROOT}%{REQUEST_URI} -f
  RewriteRule  ^(.*)$ $1 [QSA,L]

  # Rewrite to check for Rails cached html page
  RewriteCond  %{THE_REQUEST} ^(GET|HEAD)

 RewriteCond  %{DOCUMENT_ROOT}%{REQUEST_URI}.html -f
  RewriteRule  ^(.*)$ $1.html [QSA,L]


&lt/VirtualHost&gt

Questions

  1. I don't understand why this would be a permissions issue because staging.abcxyz.com can already access the folder. Am i missing something here since both are served from the same directory

  2. Could it be something to do the with the PassengerAppGroupName - but i'm not particularly concerned about having a separate worker send respond to a particular request

I'd really appreciate any help on this. Thanks.

Update

A thing that i notice is if I use the R [redirect] flag instead of the P [proxy] the application works and redirects to the right url but i want to be an internal redirect which does not reflect on the browser.

Sid
  • 6,134
  • 9
  • 34
  • 57

0 Answers0