diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-09-24 16:46:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-24 16:46:05 +0200 |
commit | 6465972caf77cb7008e1d751778f53ed2e6f698e (patch) | |
tree | d31a29f5910fae69e8ecf09959bfbc59cdc71007 /dist | |
parent | 9f6662fcc979d497b09fbd9b3ab06dd7538b92c9 (diff) |
Add nginx and systemd templates (#8770)
So they can be copied during installation instead of looking them up in the documentation Make default sidekiq configuration use weighted queues Remove deprecated docs directory
Diffstat (limited to 'dist')
-rw-r--r-- | dist/mastodon-sidekiq.service | 17 | ||||
-rw-r--r-- | dist/mastodon-streaming.service | 17 | ||||
-rw-r--r-- | dist/mastodon-web.service | 17 | ||||
-rw-r--r-- | dist/nginx.conf | 106 |
4 files changed, 157 insertions, 0 deletions
diff --git a/dist/mastodon-sidekiq.service b/dist/mastodon-sidekiq.service new file mode 100644 index 000000000..721a86609 --- /dev/null +++ b/dist/mastodon-sidekiq.service @@ -0,0 +1,17 @@ +[Unit] +Description=mastodon-sidekiq +After=network.target + +[Service] +Type=simple +User=mastodon +WorkingDirectory=/home/mastodon/live +Environment="RAILS_ENV=production" +Environment="DB_POOL=25" +Environment="MALLOC_ARENA_MAX=2" +ExecStart=/home/mastodon/.rbenv/shims/bundle exec sidekiq -c 25 +TimeoutSec=15 +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/dist/mastodon-streaming.service b/dist/mastodon-streaming.service new file mode 100644 index 000000000..5d7c129df --- /dev/null +++ b/dist/mastodon-streaming.service @@ -0,0 +1,17 @@ +[Unit] +Description=mastodon-streaming +After=network.target + +[Service] +Type=simple +User=mastodon +WorkingDirectory=/home/mastodon/live +Environment="NODE_ENV=production" +Environment="PORT=4000" +Environment="STREAMING_CLUSTER_NUM=1" +ExecStart=/usr/bin/npm run start +TimeoutSec=15 +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/dist/mastodon-web.service b/dist/mastodon-web.service new file mode 100644 index 000000000..30fcbec1e --- /dev/null +++ b/dist/mastodon-web.service @@ -0,0 +1,17 @@ +[Unit] +Description=mastodon-web +After=network.target + +[Service] +Type=simple +User=mastodon +WorkingDirectory=/home/mastodon/live +Environment="RAILS_ENV=production" +Environment="PORT=3000" +ExecStart=/home/mastodon/.rbenv/shims/bundle exec puma -C config/puma.rb +ExecReload=/bin/kill -SIGUSR1 $MAINPID +TimeoutSec=15 +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/dist/nginx.conf b/dist/nginx.conf new file mode 100644 index 000000000..3d5741765 --- /dev/null +++ b/dist/nginx.conf @@ -0,0 +1,106 @@ +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} + +proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHE:10m inactive=7d max_size=1g; + +server { + listen 80; + listen [::]:80; + server_name example.com; + root /home/mastodon/live/public; + location /.well-known/acme-challenge/ { allow all; } + location / { return 301 https://$host$request_uri; } +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name example.com; + + ssl_protocols TLSv1.2; + ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA; + ssl_prefer_server_ciphers on; + ssl_session_cache shared:SSL:10m; + + # Uncomment these lines once you acquire a certificate: + # ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; + # ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; + + keepalive_timeout 70; + sendfile on; + client_max_body_size 80m; + + root /home/mastodon/live/public; + + gzip on; + gzip_disable "msie6"; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 6; + gzip_buffers 16 8k; + gzip_http_version 1.1; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + add_header Strict-Transport-Security "max-age=31536000"; + + location / { + try_files $uri @proxy; + } + + location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) { + add_header Cache-Control "public, max-age=31536000, immutable"; + add_header Strict-Transport-Security "max-age=31536000"; + try_files $uri @proxy; + } + + location /sw.js { + add_header Cache-Control "public, max-age=0"; + add_header Strict-Transport-Security "max-age=31536000"; + try_files $uri @proxy; + } + + location @proxy { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header Proxy ""; + proxy_pass_header Server; + + proxy_pass http://127.0.0.1:3000; + proxy_buffering on; + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + + proxy_cache CACHE; + proxy_cache_valid 200 7d; + proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; + add_header X-Cached $upstream_cache_status; + add_header Strict-Transport-Security "max-age=31536000"; + + tcp_nodelay on; + } + + location /api/v1/streaming { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header Proxy ""; + + proxy_pass http://127.0.0.1:4000; + proxy_buffering off; + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + + tcp_nodelay on; + } + + error_page 500 501 502 503 504 /500.html; +} |