Skip to content

Instantly share code, notes, and snippets.

@system-ini
Created January 17, 2023 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save system-ini/52f560abf51dc261a20d4cd1aa0a86d9 to your computer and use it in GitHub Desktop.
Save system-ini/52f560abf51dc261a20d4cd1aa0a86d9 to your computer and use it in GitHub Desktop.
Sinatra + Passenger + Nginx
require 'sinatra'
get '/' do
'Hello Sinatra!'
end
require 'rubygems'
Gem.clear_paths
require './app'
run Sinatra::Application
# Nginx conf, for example in /etc/nginx/sites-available/myapp.com
server {
listen 80;
server_name myapp.com;
passenger_enabled on;
passenger_app_env production;
root /var/www/myapp.com/public;
passenger_ruby /usr/local/rvm/gems/ruby-2.7.1/wrappers/ruby;
location / {
try_files $uri @app;
}
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_redirect off;
}
error_log /var/log/nginx/myapp.com_error.log;
access_log /var/log/nginx/myapp.com_access.log;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment