|
|
|
|
map $http_upgrade $connection_upgrade {
|
|
|
|
|
default upgrade;
|
|
|
|
|
'' close;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
upstream backend {
|
|
|
|
|
server 127.0.0.1:3000 fail_timeout=0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
upstream streaming {
|
|
|
|
|
# Instruct nginx to send connections to the server with the least number of connections
|
|
|
|
|
# to ensure load is distributed evenly.
|
|
|
|
|
least_conn;
|
|
|
|
|
|
|
|
|
|
server 127.0.0.1:4000 fail_timeout=0;
|
|
|
|
|
# Uncomment these lines for load-balancing multiple instances of streaming for scaling,
|
|
|
|
|
# this assumes your running the streaming server on ports 4000, 4001, and 4002:
|
|
|
|
|
# server 127.0.0.1:4001 fail_timeout=0;
|
|
|
|
|
# server 127.0.0.1:4002 fail_timeout=0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 TLSv1.3;
|
|
|
|
|
|
|
|
|
|
# You can use https://ssl-config.mozilla.org/ to generate your cipher set.
|
|
|
|
|
# We recommend their "Intermediate" level.
|
|
|
|
|
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305;
|
|
|
|
|
|
|
|
|
|
ssl_prefer_server_ciphers on;
|
|
|
|
|
ssl_session_cache shared:SSL:10m;
|
|
|
|
|
ssl_session_tickets off;
|
|
|
|
|
|
|
|
|
|
# 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 99m;
|
|
|
|
|
|
|
|
|
|
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;
|
Bringing Hometown up to date with mastodon/mastodon (#1371)
This is a massive PR, so apologies for the poor performance viewing it!
This merges in the content of Mastodon 4.3.0. *This PR isn't ready to
deploy to production*, and I don't recommend trying it in a production
environment. Since I started by merging 4.3.0, this will likely have
reverted at least some of the content of the post-4.3.0 security patches
in the 4.2.x series; those will be brought back as I merge in 4.4.0 and
4.5.0.
I haven't yet tested this PR, so it may not actually run without
additional tweaks. I'm putting it up now for discussion and so multiple
people can test if we want.
---
Here's a few notes on things I ran into and thoughts I had while working
on it:
* We may want to look at `server_banner.jsx,` where I ended up undoing
the v3-style rewrite due to the new react component being used. I'm not
sure what the current goal for it is.
* I may not have 100% merged in all content from `status_action_bar`
correctly.
* There's a number of places where I updated the links for remote
usernames, and they should be tested to make sure they work. They're all
`<Permalink>` elements. I have in my notes that `status_content` might
need double-checking.
* I may also not have gotten the spoiler display right in
`status_content`.
* It looks like previous versions of Hometown had customizations to the
`media_item` display, not all of which was preserved as-is due to
surrounding rewrites. I'm not sure what the vision is and could use
another set of eyes.
* The character count rendering clashed with the newly-introduced
handling of a character count variable upstream, and I'm not sure if the
version I've got here 100% works or not.
* The navigation bar was completely rewritten and no longer has the
components Hometown was customizing; did I properly catch any
replacements? Did we handle all links to accounts to make sure they go
to the remote instance?
* Polls: I reverted the single/multiple choice toggle because upstream
has an actual proper UI for this that should be integrated in one of the
versions we’re merging in. Please double-check that the current version
looks fine to you.
* The font icons will need double-checking. Hometown made some custom
use of the font-awesome icons, while Mastodon 4.3.0 replaced
font-awesome with something else. I may not have caught all places that
font-awesome icons were being used.
* We’ll want to make sure the post display is correct, including
Hometown customizations, because the previous static post page has been
replaced with the React one.
---------
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Co-authored-by: Matt Jankowski <matt@jankowski.online>
Co-authored-by: Renaud Chaput <renchap@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: David Roetzel <david@roetzel.de>
Co-authored-by: Emelia Smith <ThisIsMissEm@users.noreply.github.com>
Co-authored-by: Jeong Arm <kjwonmail@gmail.com>
Co-authored-by: Christian Schmidt <github@chsc.dk>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Actions <noreply@github.com>
Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>
Co-authored-by: Darius Kazemi <darius.kazemi@gmail.com>
Co-authored-by: diondiondion <mail@diondiondion.com>
Co-authored-by: Echo <ChaosExAnima@users.noreply.github.com>
Co-authored-by: Shugo Maeda <shugo.maeda@gmail.com>
Co-authored-by: emilweth <7402764+emilweth@users.noreply.github.com>
Co-authored-by: Shlee <github@shl.ee>
Co-authored-by: Joshua Rogers <MegaManSec@users.noreply.github.com>
Co-authored-by: Jessica Stokes <hello@jessicastokes.net>
Co-authored-by: PGray <77597544+PGrayCS@users.noreply.github.com>
3 weeks ago
|
|
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/rss+xml text/javascript image/svg+xml image/x-icon;
|
|
|
|
|
gzip_static on;
|
|
|
|
|
|
|
|
|
|
location / {
|
|
|
|
|
try_files $uri @proxy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# If Docker is used for deployment and Rails serves static files,
|
|
|
|
|
# then needed must replace line `try_files $uri =404;` with `try_files $uri @proxy;`.
|
|
|
|
|
location = /sw.js {
|
|
|
|
|
add_header Cache-Control "public, max-age=604800, must-revalidate";
|
|
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location ~ ^/assets/ {
|
|
|
|
|
add_header Cache-Control "public, max-age=2419200, must-revalidate";
|
|
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location ~ ^/avatars/ {
|
|
|
|
|
add_header Cache-Control "public, max-age=2419200, must-revalidate";
|
|
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location ~ ^/emoji/ {
|
|
|
|
|
add_header Cache-Control "public, max-age=2419200, must-revalidate";
|
|
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location ~ ^/headers/ {
|
|
|
|
|
add_header Cache-Control "public, max-age=2419200, must-revalidate";
|
|
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location ~ ^/packs/ {
|
|
|
|
|
add_header Cache-Control "public, max-age=2419200, must-revalidate";
|
|
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location ~ ^/shortcuts/ {
|
|
|
|
|
add_header Cache-Control "public, max-age=2419200, must-revalidate";
|
|
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location ~ ^/sounds/ {
|
|
|
|
|
add_header Cache-Control "public, max-age=2419200, must-revalidate";
|
|
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location ~ ^/system/ {
|
|
|
|
|
add_header Cache-Control "public, max-age=2419200, immutable";
|
|
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
|
|
|
|
|
add_header X-Content-Type-Options nosniff;
|
|
|
|
|
add_header Content-Security-Policy "default-src 'none'; form-action 'none'";
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 $scheme;
|
|
|
|
|
proxy_set_header Proxy "";
|
|
|
|
|
|
|
|
|
|
proxy_pass http://streaming;
|
|
|
|
|
proxy_buffering off;
|
|
|
|
|
proxy_redirect off;
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
|
proxy_set_header Connection $connection_upgrade;
|
|
|
|
|
|
|
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
|
|
|
|
|
|
|
|
|
|
tcp_nodelay on;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 $scheme;
|
|
|
|
|
proxy_set_header Proxy "";
|
|
|
|
|
proxy_pass_header Server;
|
|
|
|
|
|
|
|
|
|
proxy_pass http://backend;
|
|
|
|
|
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_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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error_page 404 500 501 502 503 504 /500.html;
|
|
|
|
|
}
|