![](/img/trans.png)
[英]How can i forcefully redirect http request to https in passenger standalone with aws elastic load balancer?
[英]How prevent passenger to redirect the http request to the rails server when the request ask for a public asset?
我正在使用Apache2和Passenger提供我的Web Rails應用程序。
我正在使用Rails的資產管道來從Rails.root / public文件夾提供靜態資產。 通常,當請求資產文件時,Apache2成功找到相應的資產文件並將其提供服務。 我對此感到滿意。
但是,當資產丟失時,旅客將接管請求並將其重定向到導軌。 然后,Rails會產生404錯誤。
我的目標是防止缺少資產的Apache / Passenger重定向到Rails應用程序。 我試圖在不使用Rails的情況下產生404錯誤。 我希望Apache2一旦無法獲得資產,他就將錯誤發回。
我正在使用虛擬主機,這是我的配置文件。 (我正在使用SSL)我希望公用文件夾僅與Apache一起使用,即使文件丟失也是如此。
<VirtualHost *:443>
ServerName DOMAIN_NAME
DocumentRoot /home/RAILS_APP_PATH/public
#Here I saw some others configurations files having other directives, maybe I should add one.
PassengerFriendlyErrorPages On
RewriteEngine On
ErrorDocument 503 /503.html
RewriteCond %{REQUEST_URI} !^/503.html$
RewriteCond %{DOCUMENT_ROOT}/../tmp/maintenance.txt -f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /503.html [NC,R=503,L]
RewriteCond %{DOCUMENT_ROOT}/../tmp/maintenance.txt !-f
RewriteCond %{REQUEST_URI} ^/503.html
RewriteRule ^503.html https://DOMAIN_NAME.com/ [R=302,L]
SSLEngine ON
SSLCertificateFile /home/SSL_PATH/certificat.crt
SSLCertificateKeyFile /home/SSL_PATH/certificat.key
SSLCertificateChainFile /home/SSL_PATH/bundle.crt
</VirtualHost>
嘗試這個 :)
<Location /public>
PassengerEnabled off
</Location>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.