In order for Nginx to serve this content, we must modify the configuration file. Instead of modifying /etc/nginx/nginx.conf directly, we can make a new path at /etc/nginx/sites-available/
Finally, we still need to integrate it with NginX to make it live. Modify /etc/nginx/sites-available/my_way
upstream sinatra {
server unix:///home/ubuntu/sinatra-my-way/tmp/puma.sock;
}
server {
listen 80;
root /home/ubuntu/sinatra-my-way/public; # path to your app
server_name 13.250.4.60; # your domain or ip
location / {
try_files $uri @puma;
}
location @puma {
include proxy_params;
proxy_pass http://sinatra;
}
}
Restart Nginx sudo systemctl restart nginx. Now your Sinatra app is running on your domain.
1. Config nginx to serve static file
Create the directory for your_domain as follows, and create file index.html in this path.
Next, let’s enable the file by creating a link from it to the sites-enabled directory
In order for Nginx to serve this content, we must modify the configuration file. Instead of modifying
/etc/nginx/nginx.conf
directly, we can make a new path at/etc/nginx/sites-available/
Test nginx config and restart:
Check log nginx:
2. Sinatra app with puma and nginx
First, let's build simple Sinatra app. Create a directory for your app, maybe named
sinatra-my-way
Next, create Puma config file
puma.rb
and add below content:Create some supporting directories:
Run Sinatra app with puma config by this command:
Finally, we still need to integrate it with NginX to make it live. Modify
/etc/nginx/sites-available/my_way
Restart Nginx
sudo systemctl restart nginx
. Now your Sinatra app is running on your domain.References