0

I am getting 403 Forbidden. I have checked my nginx/error.log and get directory index of /home/deploy/apps/myapp/current/public/ is forbidden I have SSL and did a check on https://www.digicert.com/help/ and see my certificates are set up OK.

I am wondering if it could be be perhaps because I don't have any index.html file in my public folder. I am running on Rails 4.2. My public folder has assets, 404.html, 422.html, 500.html, favicon.ico and robots.txt.

My question is, should I be doing something to set up an index.html in my public folder that lets me use my /app/views/static_pages/home.html.erb (set up as root static_pages#home in my routes file)?

I would guess Nginx isn't liking that there is not an index.html to find.

I also went into my static pages controller and added:

def home

render :file => 'public/index.html'

end

This is my nginx config file without SSL

upstream puma {
  server unix:///home/laurie/apps/creativehub/shared/tmp/sockets/creativehub-puma.sock;
}

server {
  listen 80 default_server deferred;
  server_name creativecalgary.ca www.creativecalgary.ca;



  root /home/laurie/apps/creativehub/current/public;
  access_log /home/laurie/apps/creativehub/current/log/nginx.access.log;
  error_log /home/laurie/apps/creativehub/current/log/nginx.error.log info;

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

  try_files $uri/index.html $uri @puma;
  location @puma {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;

    proxy_pass http://puma;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 10M;
  keepalive_timeout 10;
}

This is my first Rails deploy. I am deploying on a digital ocean droplet using SSH on Cloud9 (with capistrano, puma, and nginx).

Laurie
  • 162
  • 1
  • 11
  • congratulations on how far you have come! We are all on the same road, just a few steps apart. First of all, you do not need (and in fact should not have) an `index.html` file in the public directory for your rails application. You should have one NGINX configuration file for your application and it should look different from what you posted. DO has some great tutorials you can reference including [this one](https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx-on-ubuntu-14-04). – steve klein Jun 19 '15 at 20:24
  • thanks so much - I have been following this DO tutorial https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma – Laurie Jun 20 '15 at 01:32
  • That tutorial refers to a single NGINX configuration file - you show two in your post and neither looks like that one. – steve klein Jun 20 '15 at 02:14
  • Thats correct. Because I had also to add an SSL block I referred to multiple tutorials one to get info on the SSL block in the nginx config https://www.digitalocean.com/community/tutorials/how-to-install-an-ssl-certificate-from-a-commercial-certificate-authority and also this one for info on nginx to get clarification on both config files https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts. It refers to /etc/nginx/conf and /etc/nginx/sites-available/sitename.config with symlink to /etc/nginx/sites-enabled/sitename.config. – Laurie Jun 20 '15 at 02:47
  • On another thread, I found https://gist.github.com/Epigene/616d397cda078fb2d176 which has an example nginx config with Puma and SSL. It helps in context of the Puma/Capistrano tutorial https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma. – Laurie Jun 20 '15 at 02:54
  • I would get the site working in plain text and then add SSL. It is pretty straightforward to add SSL but it is just a needless extra layer of complexity when you are trying to bring up a site. One last time - is that your actual NGINX configuration file in your original post? If so, it is not close to correct. If not, can you replace with your actual file? If you want help from us configuring, we will need the actual code/configuration. – steve klein Jun 20 '15 at 11:35
  • That was not the actual code, just me having a problem with the 4 sp indents. Since posting, I discovered a typo on one line of my nginx code. I had proxy_pass https://puma; (with https) fixed by changing to .. proxy_pass http://puma; (with http). No need to post the actual nginx.conf code. Next time I will post the code. – Laurie Jun 20 '15 at 15:20
  • Hi @Laurie , can you share your nginx.conf codes please? I'm having more or less the same problem which i posted here: http://stackoverflow.com/questions/42124054/were-sorry-but-something-went-wrong-rails-nginx-puma-digitalocean?noredirect=1#comment71417740_42124054 . It'll be great if you could help :) – Ryzal Yusoff Feb 09 '17 at 16:55
  • My project has changed since then. I removed the SSL Code for now. – Laurie Feb 12 '17 at 06:49
  • But here is my NGINX file. I ended up having problems with the sym link. I am not sure how to paste code in the comments section but I ended up following this tutorial https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma – Laurie Feb 12 '17 at 06:52
  • And adding SSL Certs, I followed this tutorial https://www.digitalocean.com/community/tutorials/how-to-install-an-ssl-certificate-from-a-commercial-certificate-authority – Laurie Feb 12 '17 at 06:53
  • Edited and pasted my NGINX file (without the SSL) and it works. It was working with SSL on an other site. Hope that helps. Check that your symbolic links are working. That is where I got stuck. – Laurie Feb 12 '17 at 06:59

0 Answers0