Skip to content

Instantly share code, notes, and snippets.

@ultramookie
Created April 14, 2024 19:39
Show Gist options
  • Save ultramookie/c2e1ed6ac8331291c8ee9ee366bf5ef2 to your computer and use it in GitHub Desktop.
Save ultramookie/c2e1ed6ac8331291c8ee9ee366bf5ef2 to your computer and use it in GitHub Desktop.
upstream backend {
server 127.0.0.1:8080;
}
server {
server_name NAME.TLD;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering on;
proxy_buffer_size 2k;
proxy_buffers 64 4k;
proxy_http_version 1.1;
tcp_nodelay on;
}
location /assets/ {
alias /gotosocial/web/assets/;
autoindex off;
expires 7d;
add_header Cache-Control "public";
}
location @fileserver {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering on;
proxy_buffer_size 2k;
proxy_buffers 64 4k;
proxy_http_version 1.1;
tcp_nodelay on;
}
location /fileserver/ {
alias /gotosocial/storage/;
autoindex off;
expires 1w;
add_header Cache-Control "private, immutable";
try_files $uri @fileserver;
}
client_max_body_size 40M;
listen [::]:443 ssl ipv6only=on http2;
listen 443 ssl http2;
ssl_certificate /etc/ssl/certs/CERT;
ssl_certificate_key /etc/ssl/private/KEY;
access_log /var/log/nginx/access.log combined;
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
image/svg+xml image/x-icon;
}
server {
if ($host = NAME.TLD) {
return 301 https://$host$request_uri;
}
listen 80;
listen [::]:80;
server_name NAME.TLD;
return 404;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment