Created
January 17, 2023 10:32
-
-
Save system-ini/52f560abf51dc261a20d4cd1aa0a86d9 to your computer and use it in GitHub Desktop.
Sinatra + Passenger + Nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
get '/' do | |
'Hello Sinatra!' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
Gem.clear_paths | |
require './app' | |
run Sinatra::Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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