Nginx with Lets encrypt loading "Welcome to Nginx" instead of my rails app

July 14, 2018 670 views
Nginx Let's Encrypt Ruby on Rails Ubuntu 16.04

Hello, I have recently deployed my Ruby on Rails application to a plain Ubuntu 16.04 droplet with Nginx, passenger & Let's encrypt.

The rails app worked fine without Let's encrypt but as soon as I installed it, I can't seem to understand why it's pointing to the "Welcome to Nginx" page instead of my rails app.

In /etc/nginx/sites-enabled/default I've used:

root /var/www/myapp;
root /var/www/myapp/code;
root /var/www/myapp/code/public;

This is where my application is.

Under /etc/nginx/nginx.conf I've tried using these:

user www-data;
user rails;
user root;

And I've even changed the ownership around a few times for root, rails and www-data:

sudo chown -R www-data:www-data /var/www/myapp
sudo find /var/www/myapp -type d -exec chmod 770 {} \;
sudo find /var/www/myapp -type f -exec chmod 660 {} \;

I don't know what gives... I keep getting "403 Forbidden nginx/1.14.0" but it worked fine and launched my deployed app without Let's Encrypt.

I would love some help, thank you!

2 Answers

Hello friend!

I couldn't say with absolute authority as much of this is going to be relative to your configuration, but it sounds like the configuration for HTTP and HTTPS may not match. You might check every config file starting at nginx.conf, and then any/every directory which is included by instruction in that primary file. Something is overriding what you had before, and the good news is that it has to be somewhere close by in those configurations.

Kind Regards,
Jarland

  • Hey Jarland, thanks for getting back to me on this one. After trying to change things around in my configs, I feel that I might be changing too many variables to really understand what is causing this problem. If you would be kind enough to check, I put my configs into this Pastebin:

    https://paste.ubuntu.com/p/NGjdkw563t/

    Thanks for your time, I do appreciate your help.

Let's Encrypt scripts change Nginx configuration. It happened with my Nginx installation too. I just manually installed certificates, instead of running scripts.

  • Hey Tejas, what kind of process did you follow to do that? Are there any tutorials or guides you can point me to? Thanks for the help!

Have another answer? Share your knowledge.