How do I configure nginx to serve my Sinatra app instead of default page?

131 Views Asked by At

I am trying to get a Sinatra app running on a Digital Ocean droplet.

I have started the Sinatra app running in var/www/myapp.com.

I have confirmed thin is running with pgrep -l -f thin.

When I navigate to myapp.com, the server presents the default "Welcome to nginx!" page.

I understand I need to configure a server block and place it in /etc/nginx/sites-available/.

There are two files in this directory: default and myapp.com

myapp.com looks like this:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/myapp.com/;

        server_name myapp.com www.myapp.com;

        location / {
                prox_pass http://myapp.com:4567;
        }
}

What additional steps do I need to take to server the sinatra site? Have I missed a step? Done anything wrong?

1

There are 1 best solutions below

0
Offensive_Guy On

Friend , you can delete all configuration in /etc/nginx/sites-enabled/

Go to your nginx.conf (/etc/nginx/nginx.conf and add the following code in conf :

include /nginx/conf.d/*;

now go to /etc/nginx/conf.d/

and create your new .conf with example name with nano :

nano example.conf

then write your conf :

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/myapp.com/;

    server_name myapp.com www.myapp.com;

    location / {
            prox_pass http://myapp.com:4567;
    }
 }

and do CTL+X to save your config and quit easy just do restart by service nginx restart or systemctl restart nginx

Your website should be probably online and no need to have /etc/nginx/sites-enable config even