Skip to content

Instantly share code, notes, and snippets.

@u1-liquid
Created October 23, 2019 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save u1-liquid/5b8562319d908538843cbe8e3aff6e79 to your computer and use it in GitHub Desktop.
Save u1-liquid/5b8562319d908538843cbe8e3aff6e79 to your computer and use it in GitHub Desktop.
Nginx Virtual Host setup including Misskey, Matrix-Synapse, Matrix-Riot-Web
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
proxy_cache_path /var/cache/nginx/misskey levels=1:2 keys_zone=CACHE-MSKY:10m inactive=7d max_size=1g;
server {
listen 80;
listen [::]:80;
server_name iro.moe;
root /home/misskey/live/public;
location /.well-known/acme-challenge/ { allow all; }
location /.well-known/matrix/server { default_type application/json; return 200 '{ "m.server": "iro.moe:443" }'; }
location / { return 301 https://$host$request_uri; }
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name iro.moe;
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/iro.moe/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/iro.moe/privkey.pem; # managed by Certbot
keepalive_timeout 70;
sendfile on;
client_max_body_size 80m;
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 /.well-known/matrix/server { default_type application/json; return 200 '{ "m.server": "iro.moe:443" }'; }
location /_matrix {
proxy_pass http://127.0.0.1:8008;
proxy_set_header X-Forwarded-For $remote_addr;
}
location /matrix { alias /home/matrix/riot/live; }
location /chat { alias /home/matrix/riot/live; }
location /riot { alias /home/matrix/riot/live; }
location / {
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-MSKY;
proxy_cache_valid 200 7d;
proxy_cache_valid 410 24h;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
add_header X-Cached $upstream_cache_status;
tcp_nodelay on;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment