I'm getting 403 error using passenger for rails in apache
Asked Answered
P

4

10

I've already installed the needed tools, and followed several tutorials trying to make passenger respond.

I can access static files in public folder (public/500.html or 422.hml). Yesterday I entered through a vhost, and found some passenger errors. But some time later the hosting restarted the service, and since then I have not been able to access the rails app again.

link

link

link

These are some of the links I used to configure the server. I've also read that could be a permission issue; I've checked that, but I'm not sure it's fine.

Phantasmal answered 7/8, 2013 at 14:27 Comment(2)
403 forbidden error is permission issue. Check the document root and make sure that index.php is having 644 permission. Also make sure that the index.php is having user ownership as that of 500.html which is able to access.Higinbotham
This is a Rails app, working through apache + passenger. I can access local files, like images. But when the rails should be responding, gives me that error.Phantasmal
P
1

Answer was that passenger gave me 403 because i had to set environment variable "RackEnv" on apache configuration to "development" (on my case).

Phantasmal answered 4/6, 2014 at 2:2 Comment(0)
N
17

First of all check your error log. By default, it placed at /var/log/apache2/.

If you have client denied by server configuration issue, check your site conf file at /etc/apache2/sites-available/your-site.conf. It must be in compliance with Phusion Passenger User Guide. Take a look on Require all granted.

<Directory "/home/user/folder">
    Require all granted 
    Options FollowSymLinks
    # This relaxes Apache security settings.
    AllowOverride None
    # MultiViews must be turned off.
    Order allow,deny
    Allow from all
</Directory>
Niece answered 26/10, 2013 at 16:19 Comment(1)
Seems that Require all granted is required if you're using Apache >= 2.4Michael
M
5

OK for me this meant I was running rails 2.3 and using Phusion Passenger 5.x

Apparently 5.x doesn't work with 2.2 at all, and with 2.3 requires you to copy in a config.ru file first (so that rails will use rack for the backend).

example config.ru file for 2.3:

# Rack Dispatcher

# Require your environment file to bootstrap Rails
require File.dirname(__FILE__) + '/config/environment'

# Dispatch the request
run ActionController::Dispatcher.new

I could not figure out why no incantations seemed to work, it was like Passenger was ignoring my rails app.

In my /var/log/apache2/error.log file, I had this:

[Mon May 11 15:47:00.397891 2015] [autoindex:error] [pid 17490:tid 3058694976] [client 216.49.181.251:49248] AH01276: Cannot serve directory /home/x/y/railsapp/public/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive, referer: https://www.google.com/

Which confused the heck out of me an apparently meant "passenger isn't running on that virtual host".

If I created a public/index.html file, apache served that fine so it wasn't a permissions issue.

I also saw this, which meant passenger was starting up ok:

[ 2015-05-11 18:23:53.9594 4964/b7415700 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!

See also https://www.phusionpassenger.com/documentation/Users%20guide%20Apache%204.0.html#_i_get_a_403_forbidden_error

So basically with passenger 5.x (in the release notes it says that rails 2.2 isn't supported, 2.3 is only supported if you create a "config.ru" file in the root of your rails app. It works with old versions of rack like rails 2.3 requires, just remove your newer rack gem and install 1.1.6 or what not, remove vendored rack gems if any. GL!

Also as a side note, this message:

[Mon May 11 18:25:10.235574 2015] [core:alert] [pid 5263:tid 3017780032] [client 127.0.0.1:56737] /home/rdp/dev/prod_flds/public/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

meant "remove your public/.htaccess file it's not needed typically by passenger"

Michael answered 12/5, 2015 at 3:59 Comment(2)
wow great explanation, what would go inside of the config.ru file?Desalvo
@SurgePedroza added what mine looks like anyway, FWIW.Michael
B
2

I also got an 403 error using passenger for rails in apache on my Mac OS 10.9 (an Unix-like system). Here's some tips:

  1. You can check apache log directory and see the what happened. The directory: /var/log/apache2/error_log.
  2. Issue: Permission denied: access to / denied ( filesystem path 'path_apache_access' ) because search permissions are missing on a component of the path.

    Check 'path_apache_access' by CLI: ls -ld 'path_apache_access' and use chmod +x to change the path privilege.

    Also, note this: Httpd Wiki - (13) Permission Denied-.

  3. Issue: configuration error: couldn't perform authentication. AuthType not set!.

    Issue: client denied by server configuration.

    Go to /etc/apache2/httpd.conf and take a look on <Directory> tag.

    Check apache version by CLI: apachectl -v, if Apache < 2.4, do NOT uncomment "Require all granted".

    <Directory "rails_app_directory/public">
          # This relaxes Apache security settings.
          AllowOverride all
          # MultiViews must be turned off.
          Options -MultiViews
          # Uncomment this if you're on Apache >= 2.4:
          # Require all granted
          Options FollowSymLinks
          Order allow,deny
          Allow from all
    </Directory>
    
Burmeister answered 11/3, 2015 at 12:32 Comment(0)
P
1

Answer was that passenger gave me 403 because i had to set environment variable "RackEnv" on apache configuration to "development" (on my case).

Phantasmal answered 4/6, 2014 at 2:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.