Report this

What is the reason for this report?

How to setup Nginx to display Ruby on Rails Webpage?

Posted on February 3, 2024

While I was building my virtual petsite I followed the following articles listed below to setup my new web server. https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04#step-1-installing-certbot https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04 https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-22-04 https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-22-04#option-2-installing-node-js-with-apt-using-a-nodesource-ppa https://docs.digitalocean.com/products/droplets/how-to/tag/ https://www.writesoftwarewell.com/how-http-cookies-work-rails/ https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-22-04 https://www.digitalocean.com/community/tutorials/how-to-use-postgresql-with-your-ruby-on-rails-application-on-ubuntu-20-04

These articles worked really well, and I have both Ruby on Rails and Nginx active. The problem is that I am having a difficulty in getting Ruby on Rails to be displayed on https://dev.duelingpets.net.

Instead of the Ruby on Rails file, I am getting this index file from Nginx to be displayed: Success! The Duelingpets server block is working!

My current config for the nginx looks like this:

server {

        root /var/www/duelingpets.net/html;
        index index.html index.htm index.nginx-debian.html;

        server_name duelingpets.net dev.duelingpets.net;

        location / {
                try_files $uri $uri/ =404;
        }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/duelingpets.net/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/duelingpets.net/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
    if ($host = dev.duelingpets.net) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = duelingpets.net) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;
        listen [::]:80;

        server_name duelingpets.net dev.duelingpets.net;
    return 404; # managed by Certbot




}


duelingpets@DuelingpetsWS1:/etc/nginx/sites-available

When I try to change the root file from root /var/www/duelingpets.net/html; to root /var/www/duelingpets.net/html/Duelingpets/public, I get: 403 Forbidden:

nginx/1.24.0 (Ubuntu) Message to pop up.

I checked the permissions and they appear to be in working order. I want it to point to my Ruby on Rails website on dev.duelingpets.net but I can’t figure out how to do so. I also heard that Passenger is obsolete with the newer versions of Nginx so I was wonder what to use to get the Rails website to display in the browser?

Any advice would be greatly appreciated on how to get this to work.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.