Merge remote-tracking branch 'origin/translations' into develop
[akkoma] / installation / apache / akkoma-apache.conf
1 # Sample Apache config for Akkoma
2 #
3 # Simple installation instructions:
4 # 1. Install your TLS certificate. We recommend using Let's Encrypt via Certbot
5 # 2. Replace 'example.tld' with your instance's domain.
6 # 3. This assumes a Debian-style Apache config. Copy this file to
7 # /etc/apache2/sites-available/ and then activate the site by running
8 # 'a2ensite akkoma-apache.conf', then restart Apache.
9 #
10 # Optional: enable disk-based caching for the media proxy
11 # For details, see https://docs.akkoma.dev/stable/configuration/howto_mediaproxy/
12 #
13 # 1. Create a directory as shown below for the CacheRoot and make sure
14 # the Apache user can write to it.
15 # 2. Configure Apache's htcacheclean to clean the directory periodically.
16 # Your OS may provide a service you can enable to do this automatically.
17
18 Define servername example.tld
19
20 <IfModule !proxy_module>
21 LoadModule proxy_module libexec/apache24/mod_proxy.so
22 </IfModule>
23 <IfModule !proxy_http_module>
24 LoadModule proxy_http_module libexec/apache24/mod_proxy_http.so
25 </IfModule>
26 <IfModule !proxy_wstunnel_module>
27 LoadModule proxy_wstunnel_module libexec/apache24/mod_proxy_wstunnel.so
28 </IfModule>
29 <IfModule !rewrite_module>
30 LoadModule rewrite_module libexec/apache24/mod_rewrite.so
31 </IfModule>
32 <IfModule !ssl_module>
33 LoadModule ssl_module libexec/apache24/mod_ssl.so
34 </IfModule>
35 <IfModule !cache_module>
36 LoadModule cache_module libexec/apache24/mod_cache.so
37 </IfModule>
38 <IfModule !cache_disk_module>
39 LoadModule cache_disk_module libexec/apache24/mod_cache_disk.so
40 </IfModule>
41
42 ServerName ${servername}
43 ServerTokens Prod
44
45 # If you want Akkoma-specific logs
46 #ErrorLog /var/log/httpd-akkoma-error.log
47 #CustomLog /var/log/httpd-akkoma-access.log combined
48
49 <VirtualHost *:80>
50 RewriteEngine on
51 RewriteCond %{SERVER_NAME} =${servername}
52 RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
53 </VirtualHost>
54
55 <VirtualHost *:443>
56 SSLEngine on
57 SSLCertificateFile /etc/letsencrypt/live/${servername}/fullchain.pem
58 SSLCertificateKeyFile /etc/letsencrypt/live/${servername}/privkey.pem
59 # Make sure you have the certbot-apache module installed
60 Include /etc/letsencrypt/options-ssl-apache.conf
61
62 # Uncomment the following to enable MediaProxy caching on disk
63 #CacheRoot /tmp/akkoma-media-cache/
64 #CacheDirLevels 1
65 #CacheDirLength 2
66 #CacheEnable disk /proxy
67 #CacheLock on
68 #CacheHeader on
69 #CacheDetailHeader on
70 ## 16MB max filesize for caching, configure as desired
71 #CacheMaxFileSize 16000000
72 #CacheDefaultExpire 86400
73
74 RewriteEngine On
75 RewriteCond %{HTTP:Connection} Upgrade [NC]
76 RewriteCond %{HTTP:Upgrade} websocket [NC]
77 RewriteRule /(.*) ws://127.0.0.1:4000/$1 [P,L]
78
79 #ProxyRequests must be off or you open your server to abuse as an open proxy
80 ProxyRequests off
81 ProxyPass / http://127.0.0.1:4000/
82 ProxyPassReverse / http://127.0.0.1:4000/
83 ProxyPreserveHost On
84 </VirtualHost>