summaryrefslogtreecommitdiff
path: root/installation
diff options
context:
space:
mode:
Diffstat (limited to 'installation')
-rwxr-xr-xinstallation/apache-cache-purge.sh.example36
-rw-r--r--installation/caddyfile-pleroma.example31
-rwxr-xr-xinstallation/download-mastofe-build.sh48
-rw-r--r--installation/pleroma-apache.conf91
-rwxr-xr-xinstallation/pleroma-mongooseim.cfg2
-rw-r--r--installation/pleroma.nginx13
-rw-r--r--installation/pleroma.vcl42
7 files changed, 115 insertions, 148 deletions
diff --git a/installation/apache-cache-purge.sh.example b/installation/apache-cache-purge.sh.example
new file mode 100755
index 000000000..7b4262875
--- /dev/null
+++ b/installation/apache-cache-purge.sh.example
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# A simple shell script to delete a media from Apache's mod_disk_cache.
+# You will likely need to setup a sudo rule like the following:
+#
+# Cmnd_Alias HTCACHECLEAN = /usr/local/sbin/htcacheclean
+# pleroma ALL=HTCACHECLEAN, NOPASSWD: HTCACHECLEAN
+#
+# Please also ensure you have enabled:
+#
+# config :pleroma, Pleroma.Web.MediaProxy.Invalidation.Script, url_format: :htcacheclean
+#
+# which will correctly format the URLs passed to this script for the htcacheclean utility.
+#
+
+SCRIPTNAME=${0##*/}
+
+# mod_disk_cache directory
+CACHE_DIRECTORY="/tmp/pleroma-media-cache"
+
+## Removes an item via the htcacheclean utility
+## $1 - the filename, can be a pattern .
+## $2 - the cache directory.
+purge_item() {
+ sudo htcacheclean -v -p "${2}" "${1}"
+} # purge_item
+
+purge() {
+ for url in $@
+ do
+ echo "$SCRIPTNAME delete \`$url\` from cache ($CACHE_DIRECTORY)"
+ purge_item "$url" $CACHE_DIRECTORY
+ done
+}
+
+purge $@
diff --git a/installation/caddyfile-pleroma.example b/installation/caddyfile-pleroma.example
index 7985d9c67..cc7dda011 100644
--- a/installation/caddyfile-pleroma.example
+++ b/installation/caddyfile-pleroma.example
@@ -5,34 +5,13 @@
# 2. Copy this section into your Caddyfile and restart Caddy.
example.tld {
- log /var/log/caddy/pleroma_access.log
- errors /var/log/caddy/pleroma_error.log
+ log {
+ output file /var/log/caddy/pleroma.log
+ }
- gzip
+ encode gzip
# this is explicitly IPv4 since Pleroma.Web.Endpoint binds on IPv4 only
# and `localhost.` resolves to [::0] on some systems: see issue #930
- proxy / 127.0.0.1:4000 {
- websocket
- transparent
- }
-
- tls {
- # Remove the rest of the lines in here, if you want to support older devices
- key_type p256
- ciphers ECDHE-ECDSA-WITH-CHACHA20-POLY1305 ECDHE-RSA-WITH-CHACHA20-POLY1305 ECDHE-ECDSA-AES256-GCM-SHA384 ECDHE-RSA-AES256-GCM-SHA384 ECDHE-ECDSA-AES128-GCM-SHA256 ECDHE-RSA-AES128-GCM-SHA256
- }
-
- # If you do not want to use the mediaproxy function, remove these lines.
- # To use this directive, you need the http.cache plugin for Caddy.
- cache {
- match_path /media
- default_max_age 720m
- }
-
- cache {
- match_path /proxy
- default_max_age 720m
- }
- # Stop removing lines here.
+ reverse_proxy 127.0.0.1:4000
}
diff --git a/installation/download-mastofe-build.sh b/installation/download-mastofe-build.sh
deleted file mode 100755
index b8a021ef3..000000000
--- a/installation/download-mastofe-build.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/sh
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-project_id="74"
-project_branch="rebase/glitch-soc"
-static_dir="instance/static"
-# For bundling:
-# project_branch="pleroma"
-# static_dir="priv/static"
-
-if [ ! -d "${static_dir}" ]
-then
- echo "Error: ${static_dir} directory is missing, are you sure you are running this script at the root of pleroma’s repository?"
- exit 1
-fi
-
-last_modified="$(curl --fail -s -I 'https://git.pleroma.social/api/v4/projects/'${project_id}'/jobs/artifacts/'${project_branch}'/download?job=build' | grep '^Last-Modified:' | cut -d: -f2-)"
-
-echo "branch:${project_branch}"
-echo "Last-Modified:${last_modified}"
-
-artifact="mastofe.zip"
-
-if [ "${last_modified}x" = "x" ]
-then
- echo "ERROR: Couldn't get the modification date of the latest build archive, maybe it expired, exiting..."
- exit 1
-fi
-
-if [ -e mastofe.timestamp ] && [ "$(cat mastofe.timestamp)" = "${last_modified}" ]
-then
- echo "MastoFE is up-to-date, exiting..."
- exit 0
-fi
-
-curl --fail -c - "https://git.pleroma.social/api/v4/projects/${project_id}/jobs/artifacts/${project_branch}/download?job=build" -o "${artifact}" || exit
-
-# TODO: Update the emoji as well
-rm -fr "${static_dir}/sw.js" "${static_dir}/packs" || exit
-unzip -q "${artifact}" || exit
-
-cp public/assets/sw.js "${static_dir}/sw.js" || exit
-cp -r public/packs "${static_dir}/packs" || exit
-
-echo "${last_modified}" > mastofe.timestamp
-rm -fr public
-rm -i "${artifact}"
diff --git a/installation/pleroma-apache.conf b/installation/pleroma-apache.conf
index 0d627f2d7..139abe9e1 100644
--- a/installation/pleroma-apache.conf
+++ b/installation/pleroma-apache.conf
@@ -1,73 +1,84 @@
-# default Apache site config for Pleroma
-#
-# needed modules: define headers proxy proxy_http proxy_wstunnel rewrite ssl
-# optional modules: cache cache_disk
+# Sample Apache config for Pleroma
#
# Simple installation instructions:
-# 1. Install your TLS certificate, possibly using Let's Encrypt.
-# 2. Replace 'example.tld' with your instance's domain wherever it appears.
-# 3. This assumes a Debian style Apache config. Copy this file to
-# /etc/apache2/sites-available/ and then add a symlink to it in
-# /etc/apache2/sites-enabled/ by running 'a2ensite pleroma-apache.conf', then restart Apache.
+# 1. Install your TLS certificate. We recommend using Let's Encrypt via Certbot
+# 2. Replace 'example.tld' with your instance's domain.
+# 3. This assumes a Debian-style Apache config. Copy this file to
+# /etc/apache2/sites-available/ and then activate the site by running
+# 'a2ensite pleroma-apache.conf', then restart Apache.
#
# Optional: enable disk-based caching for the media proxy
# For details, see https://git.pleroma.social/pleroma/pleroma/wikis/How%20to%20activate%20mediaproxy
#
-# 1. Create the directory listed below as the CacheRoot, and make sure
+# 1. Create a directory as shown below for the CacheRoot and make sure
# the Apache user can write to it.
# 2. Configure Apache's htcacheclean to clean the directory periodically.
-# 3. Run 'a2enmod cache cache_disk' and restart Apache.
+# Your OS may provide a service you can enable to do this automatically.
Define servername example.tld
+<IfModule !proxy_module>
+ LoadModule proxy_module libexec/apache24/mod_proxy.so
+</IfModule>
+<IfModule !proxy_http_module>
+ LoadModule proxy_http_module libexec/apache24/mod_proxy_http.so
+</IfModule>
+<IfModule !proxy_wstunnel_module>
+ LoadModule proxy_wstunnel_module libexec/apache24/mod_proxy_wstunnel.so
+</IfModule>
+<IfModule !rewrite_module>
+ LoadModule rewrite_module libexec/apache24/mod_rewrite.so
+</IfModule>
+<IfModule !ssl_module>
+ LoadModule ssl_module libexec/apache24/mod_ssl.so
+</IfModule>
+<IfModule !cache_module>
+ LoadModule cache_module libexec/apache24/mod_cache.so
+</IfModule>
+<IfModule !cache_disk_module>
+ LoadModule cache_disk_module libexec/apache24/mod_cache_disk.so
+</IfModule>
+
ServerName ${servername}
ServerTokens Prod
-ErrorLog ${APACHE_LOG_DIR}/error.log
-CustomLog ${APACHE_LOG_DIR}/access.log combined
+# If you want Pleroma-specific logs
+#ErrorLog /var/log/httpd-pleroma-error.log
+#CustomLog /var/log/httpd-pleroma-access.log combined
<VirtualHost *:80>
- Redirect permanent / https://${servername}
+ RewriteEngine on
+ RewriteCond %{SERVER_NAME} =${servername}
+ RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/${servername}/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/${servername}/privkey.pem
+ # Make sure you have the certbot-apache module installed
+ Include /etc/letsencrypt/options-ssl-apache.conf
- # Mozilla modern configuration, tweak to your needs
- SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
- SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
- SSLHonorCipherOrder on
- SSLCompression off
- SSLSessionTickets off
-
- # uncomment the following to enable mediaproxy caching on disk
- # <IfModule mod_cache_disk.c>
- # CacheRoot /var/cache/apache2/mod_cache_disk
- # CacheDirLevels 1
- # CacheDirLength 2
- # CacheEnable disk /proxy
- # CacheLock on
- # </IfModule>
+ # Uncomment the following to enable MediaProxy caching on disk
+ #CacheRoot /tmp/pleroma-media-cache/
+ #CacheDirLevels 1
+ #CacheDirLength 2
+ #CacheEnable disk /proxy
+ #CacheLock on
+ #CacheHeader on
+ #CacheDetailHeader on
+ ## 16MB max filesize for caching, configure as desired
+ #CacheMaxFileSize 16000000
+ #CacheDefaultExpire 86400
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
- RewriteRule /(.*) ws://localhost:4000/$1 [P,L]
+ RewriteRule /(.*) ws://127.0.0.1:4000/$1 [P,L]
+ #ProxyRequests must be off or you open your server to abuse as an open proxy
ProxyRequests off
- # this is explicitly IPv4 since Pleroma.Web.Endpoint binds on IPv4 only
- # and `localhost.` resolves to [::0] on some systems: see issue #930
ProxyPass / http://127.0.0.1:4000/
ProxyPassReverse / http://127.0.0.1:4000/
-
- RequestHeader set Host ${servername}
ProxyPreserveHost On
</VirtualHost>
-
-# OCSP Stapling, only in httpd 2.3.3 and later
-SSLUseStapling on
-SSLStaplingResponderTimeout 5
-SSLStaplingReturnResponderErrors off
-SSLStaplingCache shmcb:/var/run/ocsp(128000)
diff --git a/installation/pleroma-mongooseim.cfg b/installation/pleroma-mongooseim.cfg
index 576f83541..3ecba5641 100755
--- a/installation/pleroma-mongooseim.cfg
+++ b/installation/pleroma-mongooseim.cfg
@@ -466,7 +466,7 @@
%% == PostgreSQL ==
%% {rdbms, global, default, [{workers, 10}],
-%% [{server, {pgsql, "server", 5432, "database", "username", "password"}}]},
+%% [{server, {pgsql, "server", "port", "database", "username", "password"}}]},
%% == ODBC (MSSQL) ==
%% {rdbms, global, default, [{workers, 10}],
diff --git a/installation/pleroma.nginx b/installation/pleroma.nginx
index 9890cb2b1..273cfb390 100644
--- a/installation/pleroma.nginx
+++ b/installation/pleroma.nginx
@@ -81,6 +81,19 @@ server {
proxy_pass http://phoenix;
}
+ # Uncomment this if you want notice compatibility routes for frontends like Soapbox.
+ # location ~ ^/@[^/]+/([^/]+)$ {
+ # proxy_pass http://phoenix/notice/$1;
+ # }
+ #
+ # location ~ ^/@[^/]+/posts/([^/]+)$ {
+ # proxy_pass http://phoenix/notice/$1;
+ # }
+ #
+ # location ~ ^/[^/]+/status/([^/]+)$ {
+ # proxy_pass http://phoenix/notice/$1;
+ # }
+
location ~ ^/(media|proxy) {
proxy_cache pleroma_media_cache;
slice 1m;
diff --git a/installation/pleroma.vcl b/installation/pleroma.vcl
index 13dad784c..4eb2f3cfa 100644
--- a/installation/pleroma.vcl
+++ b/installation/pleroma.vcl
@@ -1,4 +1,5 @@
# Recommended varnishncsa logging format: '%h %l %u %t "%m %{X-Forwarded-Proto}i://%{Host}i%U%q %H" %s %b "%{Referer}i" "%{User-agent}i"'
+# Please use Varnish 7.0+ for proper Range Requests / Chunked encoding support
vcl 4.1;
import std;
@@ -22,11 +23,6 @@ sub vcl_recv {
set req.http.X-Forwarded-Proto = "https";
}
- # CHUNKED SUPPORT
- if (req.http.Range ~ "bytes=") {
- set req.http.x-range = req.http.Range;
- }
-
# Pipe if WebSockets request is coming through
if (req.http.upgrade ~ "(?i)websocket") {
return (pipe);
@@ -35,9 +31,9 @@ sub vcl_recv {
# Allow purging of the cache
if (req.method == "PURGE") {
if (!client.ip ~ purge) {
- return(synth(405,"Not allowed."));
+ return (synth(405,"Not allowed."));
}
- return(purge);
+ return (purge);
}
}
@@ -53,10 +49,11 @@ sub vcl_backend_response {
return (retry);
}
- # CHUNKED SUPPORT
- if (bereq.http.x-range ~ "bytes=" && beresp.status == 206) {
- set beresp.ttl = 10m;
- set beresp.http.CR = beresp.http.content-range;
+ # Bypass cache for large files
+ # 50000000 ~ 50MB
+ if (std.integer(beresp.http.content-length, 0) > 50000000) {
+ set beresp.uncacheable = true;
+ return (deliver);
}
# Don't cache objects that require authentication
@@ -87,7 +84,7 @@ sub vcl_synth {
if (resp.status == 750) {
set resp.status = 301;
set resp.http.Location = req.http.x-redir;
- return(deliver);
+ return (deliver);
}
}
@@ -99,25 +96,12 @@ sub vcl_pipe {
}
}
-sub vcl_hash {
- # CHUNKED SUPPORT
- if (req.http.x-range ~ "bytes=") {
- hash_data(req.http.x-range);
- unset req.http.Range;
- }
-}
-
sub vcl_backend_fetch {
# Be more lenient for slow servers on the fediverse
if (bereq.url ~ "^/proxy/") {
set bereq.first_byte_timeout = 300s;
}
- # CHUNKED SUPPORT
- if (bereq.http.x-range) {
- set bereq.http.Range = bereq.http.x-range;
- }
-
if (bereq.retries == 0) {
# Clean up the X-Varnish-Backend-503 flag that is used internally
# to mark broken backend responses that should be retried.
@@ -136,14 +120,6 @@ sub vcl_backend_fetch {
}
}
-sub vcl_deliver {
- # CHUNKED SUPPORT
- if (resp.http.CR) {
- set resp.http.Content-Range = resp.http.CR;
- unset resp.http.CR;
- }
-}
-
sub vcl_backend_error {
# Retry broken backend responses.
set bereq.http.X-Varnish-Backend-503 = "1";