Passenger Apache Rails 403 is prohibited. 2 urls indicating the same application 1 works, others do not

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.


&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

  • 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.

+4

All Articles