The problem came from an .htaccess in /var/ which affected my site in /var/landing-page.
Rails4: Request exceeded the limit of 10 internal redirects due to probable configuration error
-
17-06-2023 - |
質問
I'm hosting a rails 4 application with phusion passenger on a apache server and I'm getting a 500 error when I try to access my password protected admin pages.
Looking at the log I see I'm getting an "Request exceeded the limit of 10 internal redirects due to probable configuration error."
I have looked on the web and SO, it seems this is usually coming from a badly configured .htaccess. The problem is my application is using http_basic_authenticate_with so I am unsure how to correct the problem.
Here is my admin_controller.rb with the authentification:
class AdminController < ApplicationController
@config_name = CONFIG["name"]
@config_password = CONFIG["password"]
http_basic_authenticate_with :name => @config_name,
:password => @config_password,
:realm => (I18n.t "msg_authentication")
Here is my routes.rb (I don't think the error comes from here):
LandingPage::Application.routes.draw do
get "admin/gestion"
get "admin/download"
get "admin/email"
get "admin/show"
get "admin/new"
get "admin/validate"
get "admin", to: "admin#home"
root 'main#home'
resources :mail_infos, controller: :main, :path => "/"
resources :mail_bodies, controller: :admin, :path => "/admin"
end
My virtual host code:
PassengerRuby /usr/local/rvm/gems/ruby-2.1.0/wrappers/ruby
<VirtualHost *:80>
ServerName DOMAIN.com
DocumentRoot /var/landing-page/public
<Directory /var/landing-page/public>
Allow from all
Options -MultiViews
</Directory>
RewriteEngine off
LogLevel debug
ErrorLog /var/log/apache2/landing-page.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
# LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
Here is my log for apache rendering the application:
[Wed Mar 19 13:44:51 2014] [error] [client 98.14.198.144] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Mar 19 13:44:51 2014] [debug] core.c(3063): [client 98.14.198.144] r->uri = /index.php
[Wed Mar 19 13:44:51 2014] [debug] core.c(3069): [client 98.14.198.144] redirected from r->uri = /index.php
[Wed Mar 19 13:44:51 2014] [debug] core.c(3069): [client 98.14.198.144] redirected from r->uri = /index.php
[Wed Mar 19 13:44:51 2014] [debug] core.c(3069): [client 98.14.198.144] redirected from r->uri = /index.php
[Wed Mar 19 13:44:51 2014] [debug] core.c(3069): [client 98.14.198.144] redirected from r->uri = /index.php
[Wed Mar 19 13:44:51 2014] [debug] core.c(3069): [client 98.14.198.144] redirected from r->uri = /index.php
[Wed Mar 19 13:44:51 2014] [debug] core.c(3069): [client 98.14.198.144] redirected from r->uri = /index.php
[Wed Mar 19 13:44:51 2014] [debug] core.c(3069): [client 98.14.198.144] redirected from r->uri = /index.php
[Wed Mar 19 13:44:51 2014] [debug] core.c(3069): [client 98.14.198.144] redirected from r->uri = /index.php
[Wed Mar 19 13:44:51 2014] [debug] core.c(3069): [client 98.14.198.144] redirected from r->uri = /index.php
[Wed Mar 19 13:44:51 2014] [debug] core.c(3069): [client 98.14.198.144] redirected from r->uri = /admin
[Wed Mar 19 13:44:51 2014] [debug] mod_deflate.c(615): [client 98.14.198.144] Zlib: Compressed 632 to 387 : URL /index.php
Rails probably makes something similar to an .htaccess with http_basic_authenticate_with. So if I could get how to modify the http_basic_authenticate_with like people usually modify the .htaccess that would be great, thanks.
EDIT: As suspected by Chuanpin Zhu, the issue doesn't seem to actually do with the http_basic_authenticate_with method. I've commented it out and it still had an issue. As a matter of fact if I try to go to:
DOMAIN.com/none-existing-page
I still get the 500 serveur error and the "redirected from r->uri = /index.php" message. When in all logic I should get a 404 error.
If I comment out the "root" command in routes.rb DOMAIN.com gives a 404 error, yet DOMAIN.com/none-existing-page still gives out a 500 apache error.
解決 2
他のヒント
you might have a recursive redirect_to method. Looking though the log,
redirected from r->uri = /index.php
this redirected_to shows more than 10 times, so please check your related controllers, or post it.