krs
krs

Reputation: 1537

403 forbidden error in Passenger+Nginx+rails configuration

I have installed nginx+passenger in amazon-linux. By rvmsudo passenger-install-nginx-module

After I edited /var/opt/nginx/nginx.conf as below:

root /home/ec2-user/current/public/index;

server {

    listen       80;

    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root  /home/ec2-user/current/public/index;
        index  index.html index.htm;
    }

I had thrown with 403 forbidden error and so, I checked my path, it was correct.

enter image description here

Thanks in advance

Upvotes: 1

Views: 1838

Answers (2)

Hongli
Hongli

Reputation: 18924

Your permissions are too strict and don't allow Nginx to access your root directory. Relax permissions like this:

chmod o+x /home/ec2-user/current
chmod o+x /home/ec2-user

Upvotes: 3

CDub
CDub

Reputation: 13354

I think you want your nginx config to point the root just to the public folder:

root /home/ec2-user/current/public;

server {

    listen       80;

    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root  /home/ec2-user/current/public;
        index  index.html index.htm;
    }

Upvotes: 1

Related Questions