Created
December 3, 2022 16:54
-
-
Save perillamint/924386425c2dc120267d3b4bf8b95349 to your computer and use it in GitHub Desktop.
Mastodon docker nginx
This file contains hidden or 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
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name example.com; | |
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot | |
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | |
# include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |
# include snippets/global.conf; | |
include snippets/ciphers.conf; | |
client_max_body_size 0; | |
location / { | |
try_files $uri @proxy; | |
} | |
location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) { | |
add_header Cache-Control "public, max-age=31536000, immutable"; | |
try_files $uri @proxy; | |
} | |
location /sw.js { | |
add_header Cache-Control "public, max-age=0"; | |
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; | |
# Avoid 504 HTTP Timeout Errors | |
proxy_connect_timeout 605; | |
proxy_send_timeout 605; | |
proxy_read_timeout 605; | |
send_timeout 605; | |
keepalive_timeout 605; | |
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://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; | |
} | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name example.com; | |
return 301 https://$host$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment