0
votes

I'm using Amazon EC2 and tried to deploy a rails project. I have install nginx/passenger and successfully made nginx server run.

I started my rails project with name "forfun" then I set the root of nginx to /home/ubuntu/rails/forfun/public

I initialized a file named "index.html", then I could see the page in browser (http://[my ip]:80)

However, what i really wanna see is the welcome page of rails app.

I tried do remove index.html and see what i got. I saw 404 Forbidden error. /var/log/nginx/error.log reveals that directory index of "/home/ubuntu/rails/forfun/public/" is forbidden

What step i actually missed?

by the way, do i need to do "rails server" while nginx is running?

ps: (1) /opt/nginx/conf/nginx.conf


    http {
    passenger_root /usr/local/rvm/gems/ruby-2.3.0/gems/passenger-5.0.26;
    passenger_ruby /usr/local/rvm/gems/ruby-2.3.0/wrappers/ruby;
    ... 
        server {
        listen       80;
        server_name  52.196.XX.XXX;#my amazon public ip
            root /home/ubuntu/rails/forfuni/public;
        }

(2)/etc/nginx/sites-enabled/default


    server {

        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /home/ubuntu/rails/forfun/public;
        index index.html index.htm;
    }

1
Does ec2 security group allow access to port 80. You can see in on ec2 console.Shishir
You mean the welcome to rails page that shows info like which version of rails is installed etc?Frederick Cheung
@Shishir, yes, ec2 security group do allow access to port 80, and 3000yushengc

1 Answers

0
votes

Try adding /etc/nginx/sites-enabled/default

server {
 listen 80 default_server;
 server_name  52.196.XX.XXX;#my amazon public ip;

 passenger_enabled on;
 passenger_app_env development; #or whatever rails env you want.

The whole process of deploying a rails app using nginx/passenger is documented here. See the nginx section.

https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-nginx-on-ubuntu-14-04