Skip to content

Instantly share code, notes, and snippets.

@JanDeDobbeleer
Last active May 2, 2017 06:07
Show Gist options
  • Save JanDeDobbeleer/0b0a425e8639d980bc430ea22c14710c to your computer and use it in GitHub Desktop.
Save JanDeDobbeleer/0b0a425e8639d980bc430ea22c14710c to your computer and use it in GitHub Desktop.
nginx configuration for mastodon.herebedragons.io
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
# set root and server_name here
root /var/www/html;
server_name mastodon.herebedragons.io;
# Useful for Let's Encrypt
location /.well-known/acme-challenge/ { allow all; }
location / { return 301 https://$host$request_uri; }
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name mastodon.herebedragons.io;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_certificate /etc/letsencrypt/live/mastodon.herebedragons.io/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mastodon.herebedragons.io/privkey.pem;
keepalive_timeout 70;
sendfile on;
client_max_body_size 0;
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=63072000; includeSubdomains";
add_header Content-Security-Policy "script-src 'self' 'unsafe-inline' 'unsafe-eval' *.cloudflare.com; object-src 'self'; frame-ancestors 'self'";
add_header X-Welcome-Stanger "Hi there, welcome to my personal Mastodon instance, make sure to follow me!";
add_header X-Blog-Location "https://herebedragons.io/";
add_header X-GitHub-Location "https://github.com/janjoris";
add_header X-StackOverflow-Location "https://www.stackoverflow.com/users/5122929/jan";
add_header X-Keybase-Location "https://keybase.io/janjoris";
add_header X-Twitter-Location "https://twitter.com/jan_joris";
add_header X-Facebook-Location "https://www.facebook.com/janjoris";
add_header X-LinkedIn-Location "https://www.linkedin.com/in/jandedobbeleer";
add_header X-Instagram-Location "https://instagram.com/jan__joris";
location / {
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 off;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
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://localhost: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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment