Skip to content

Instantly share code, notes, and snippets.

@danirod
Last active November 9, 2022 03:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danirod/81c28adab3a600771600d46418f47956 to your computer and use it in GitHub Desktop.
Save danirod/81c28adab3a600771600d46418f47956 to your computer and use it in GitHub Desktop.
nginx + systemd + puma
# Certificates used by makigas.es
ssl_certificate /etc/letsencrypt/live/www.makigas.es/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.makigas.es/privkey.pem;
## ##
#######
####### m a k i g a s . e s
## # ##
## ##
# web application socket
upstream makigas {
server unix:///var/www/makigas/shared/tmp/sockets/puma.sock;
}
# http://*.makigas.es -> https://www.makigas.es
server {
listen 80;
listen [::]:80;
server_name .makigas.es;
return 301 https://www.makigas.es$request_uri;
}
# https://makigas.es -> https://www.makigas.es
server {
listen 443;
listen [::]:443 ssl;
server_name makigas.es;
include /etc/nginx/sites-available/include/makigas-encrypt.conf;
return 301 https://www.makigas.es$request_uri;
}
# https://www.makigas.es
server {
listen 443 http2 ssl;
listen [::]:443 http2 ssl;
server_name www.makigas.es;
include /etc/nginx/sites-available/include/makigas-encrypt.conf;
access_log /var/log/nginx/makigas.access.log;
error_log /var/log/nginx/makigas.error.log;
root /var/www/makigas/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
location ~* \.(woff|eot|ttf|svg|mp4|webm|jpg|jpeg|png|gif|ico|css|js)$ {
gzip_static on;
expires 6h;
add_header Cache-Control public;
}
try_files $uri @makigas;
error_page 404 /404.html;
error_page 500 501 503 /500.html;
error_page 502 /502.html;
location @makigas {
proxy_pass http://makigas;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
[Unit]
Description=makigas.es web application
[Service]
Type=simple
User=makigaseml
WorkingDirectory=/var/www/makigas/current
Environment=WEB_CONCURRENCY=1
ExecStart=/usr/local/rvm/wrappers/default/bundle exec puma -e production
Restart=always
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment