Created
January 7, 2024 08:24
-
-
Save julienbourdeau/5d5edc2da97f5a35ba4003e6918e0920 to your computer and use it in GitHub Desktop.
Rails on a bare metal server
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
upstream puma { | |
server 127.0.0.1:3000; | |
} | |
server { | |
server_name yolo.com; | |
client_max_body_size 200m; | |
gzip on; | |
gzip_comp_level 4; | |
gzip_min_length 1000; | |
gzip_proxied expired no-cache no-store private auth; | |
gzip_types text/plain application/javascript application/json application/x-javascript text/xml text/css application/xml text/javascript; | |
root /home/ubuntu/yolo.com; | |
location / { | |
try_files $uri @app; | |
} | |
location @app { | |
proxy_pass http://puma; | |
proxy_headers_hash_max_size 102410; | |
proxy_headers_hash_bucket_size 1024; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "Upgrade"; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header X-Forwarded-Proto https; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
} | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/yolo.com/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/yolo.com/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 = yolo.com { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
server_name yolo.com; | |
listen 80; | |
return 404; # managed by Certbot | |
} |
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
sudo apt install mysql-server mysql-client libmysqlclient-dev | |
sudo apt install nginx | |
sudo apt install certbot python3-certbot-nginx | |
# /etc/systemd/system/puma.service |
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
[Unit] | |
Description=Puma HTTP Server | |
After=network.target | |
[Service] | |
Type=simple | |
User=root | |
Group=root | |
WorkingDirectory=/home/ubuntu/yolo.com | |
Environment=RAILS_ENV=production | |
Environment=WEB_CONCURRENCY=0 | |
Environment=YOLO_DATABASE_PASSWORD=THIS_IS_A_PASSWORD | |
ExecStart=/home/ubuntu/.rbenv/shims/ruby /home/ubuntu/yolo.com/bin/rails server | |
Restart=always | |
KillMode=process | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment