installation/pleroma-apache.conf: Add TLS configuration and security headers
[akkoma] / installation / pleroma-apache.conf
1 #Example configuration for when Apache httpd and Pleroma are on the same host.
2 #Needed modules: headers proxy proxy_http proxy_wstunnel rewrite ssl
3 #This assumes a Debian style Apache config. Put this in /etc/apache2/sites-available
4 #Install your TLS certificate, possibly using Let's Encrypt.
5 #Replace 'pleroma.example.com' with your instance's domain wherever it appears
6
7 ServerName pleroma.example.com
8 ServerTokens Prod
9
10 ErrorLog ${APACHE_LOG_DIR}/error.log
11 CustomLog ${APACHE_LOG_DIR}/access.log combined
12
13 <VirtualHost *:80>
14 Redirect permanent / https://pleroma.example.com
15 </VirtualHost>
16
17 <VirtualHost *:443>
18 SSLEngine on
19 SSLCertificateFile /etc/letsencrypt/live/pleroma.example.com/cert.pem
20 SSLCertificateKeyFile /etc/letsencrypt/live/pleroma.example.com/privkey.pem
21 SSLCertificateChainFile /etc/letsencrypt/live/pleroma.example.com/fullchain.pem
22
23 # Mozilla modern configuration, tweak to your needs
24 SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
25 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
26 SSLHonorCipherOrder on
27 SSLCompression off
28 SSLSessionTickets off
29
30 # OCSP Stapling, only in httpd 2.3.3 and later
31 SSLUseStapling on
32 SSLStaplingResponderTimeout 5
33 SSLStaplingReturnResponderErrors off
34 SSLStaplingCache shmcb:/var/run/ocsp(128000)
35
36 Header always set X-Xss-Protection "1; mode=block"
37 Header always set X-Frame-Options "DENY"
38 Header always set X-Content-Type-Options "nosniff"
39 Header always set Referrer-Policy same-origin
40 Header always set Content-Security-Policy "default-src 'none'; base-uri 'self'; form-action 'self'; img-src 'self' data: https:; media-src 'self' https:; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self'; connect-src 'self' wss://pleroma.example.tld; upgrade-insecure-requests;"
41
42 # Uncomment this only after you get HTTPS working.
43 # Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
44
45 RewriteEngine On
46 RewriteCond %{HTTP:Connection} Upgrade [NC]
47 RewriteCond %{HTTP:Upgrade} websocket [NC]
48 RewriteRule /(.*) ws://localhost:4000/$1 [P,L]
49
50 ProxyRequests off
51 ProxyPass / http://localhost:4000/
52 ProxyPassReverse / http://localhost:4000/
53
54 RequestHeader set Host "pleroma.example.com"
55 ProxyPreserveHost On
56 </VirtualHost>