4

同じRailsアプリケーションを指している2つの別々のURLがあるという奇妙な問題があります

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

私のセットアップはパッセンジャーでApacheを実行します。ここで注意すべき重要な点は、両方の URL がドキュメント ルート ディレクトリ内の同じ Rails アプリケーションを指しており、内部では異なる URL によって提供されているということです。

問題

staging.abcxyz.com にアクセスしようとすると、機能し、アプリケーションがレンダリングされ、すべてが期待どおりに機能します。

staging.abcttt.com にアクセスしようとすると、Apache は 403 禁止を返します。

アパッチ構成

これは、私にとっては機能しない URL の apache 構成です。URLの変更を期待して機能するものとまったく同じです。


<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
  #
  # 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
  <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

  # 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]


</VirtualHost>

質問

  1. staging.abcxyz.com は既にフォルダーにアクセスできるため、これがアクセス許可の問題になる理由がわかりません。両方が同じディレクトリから提供されているため、ここで何か不足していますか

  2. それは PassengerAppGroupName で何かをすることができますか - しかし、私は別のワーカーが特定のリクエストに応答することについて特に心配していません

これについて何か助けていただければ幸いです。ありがとう。

アップデート

私が気づいたことは、P [プロキシ] の代わりに R [リダイレクト] フラグを使用すると、アプリケーションが動作し、正しい URL にリダイレクトされますが、ブラウザーに反映されない内部リダイレクトになりたいということです。

4

0 に答える 0