-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mastodon.conf
95 lines (71 loc) · 3.62 KB
/
mastodon.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Plausible Analytics - cache
# https://plausible.io/docs/proxy/guides/nginx
# Replace mydomain.example with your mastodon domain
# Replace plausible.domain with where you installed Plausible
proxy_cache_path /var/run/nginx-cache/jscache levels=1:2 keys_zone=jscache:100m inactive=30d use_temp_path=off max_size=100m;
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
root /home/mastodon; #point to your mastodon folder
index index.html index.htm;
server_name mydomain.example www.mydomain.example;
# Replace your domain in these paths
ssl_certificate /etc/letsencrypt/live/mydomain.example/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.example/privkey.pem;
ssl_session_timeout 5m;
ssl_prefer_server_ciphers On;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
absolute_redirect off;
server_name_in_redirect off;
error_page 404 /404.html;
error_page 410 /410.html;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://127.0.0.1:3000; #confirm this is the port you are using
# Plausible Analytics Script, with outbound-links enabled
# this filter replaces the closing </body> with the script and </body>, effectively injecting the script before the end of the page; you could also replace </header> if you want the script to load sooner
# replace with your domain and script
sub_filter '</body>' '<script defer data-api="/api/event" data-domain="mydomain.example" src="/js/plausible.outbound-links.js"></script><script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script></body>';
sub_filter_once on;
}
location ^~ /api/v1/streaming {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://127.0.0.1:4000; #confirm this is the port you are using
proxy_buffering off;
proxy_redirect off;
proxy_http_version 1.1;
tcp_nodelay on;
}
# PLAUSIBLE PROXY CONFIGURATION
location = /js/plausible.outbound-links.js {
# Change this if you use a different variant of the script
# Replace plausible.domain with where you installed Plausible
proxy_pass https://plausible.domain/js/plausible.outbound-links.js;
proxy_set_header Host plausible.domain;
proxy_ssl_name plausible.domain;
proxy_ssl_server_name on;
proxy_ssl_session_reuse off;
# Tiny, negligible performance improvement. Very optional.
proxy_buffering on;
# Cache the script for 6 hours, as long as plausible.io returns a valid response
proxy_cache jscache;
proxy_cache_valid 200 6h;
proxy_cache_use_stale updating error timeout invalid_header http_500;
# Optional. Adds a header to tell if you got a cache hit or miss
add_header X-Cache $upstream_cache_status;
}
location = /api/event {
proxy_pass https://plausible.domain/api/event;
proxy_set_header Host plausible.domain;
proxy_ssl_name plausible.domain;
proxy_ssl_server_name on;
proxy_ssl_session_reuse off;
proxy_buffering on;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
}
}