@@ -44,6 +44,14 @@ Here are a few working sample configs:
44
44
attachment-cache-dir: "/var/cache/ntfy/attachments"
45
45
```
46
46
47
+ === "server.yml (behind proxy, with cache + attachments)"
48
+ ``` yaml
49
+ base-url: "http://ntfy.example.com "
50
+ listen-http: ":2586"
51
+ cache-file: "/var/cache/ntfy/cache.db"
52
+ attachment-cache-dir: "/var/cache/ntfy/attachments"
53
+ ```
54
+
47
55
=== "server.yml (ntfy.sh config)"
48
56
``` yaml
49
57
# All the things: Behind a proxy, Firebase, cache, attachments,
@@ -649,28 +657,22 @@ or the root domain:
649
657
<VirtualHost *:80>
650
658
ServerName ntfy.sh
651
659
652
- # Proxy connections to ntfy (requires "a2enmod proxy")
653
- ProxyPass / http://127.0.0.1:2586/
660
+ # Proxy connections to ntfy (requires "a2enmod proxy proxy_http ")
661
+ ProxyPass / http://127.0.0.1:2586/ upgrade=websocket
654
662
ProxyPassReverse / http://127.0.0.1:2586/
655
663
656
664
SetEnv proxy-nokeepalive 1
657
665
SetEnv proxy-sendchunked 1
658
666
659
667
# Higher than the max message size of 4096 bytes
660
668
LimitRequestBody 102400
661
-
662
- # Enable mod_rewrite (requires "a2enmod rewrite")
663
- RewriteEngine on
664
-
665
- # WebSockets support (requires "a2enmod rewrite proxy_wstunnel")
666
- RewriteCond %{HTTP:Upgrade} websocket [NC]
667
- RewriteCond %{HTTP:Connection} upgrade [NC]
668
- RewriteRule ^/?(.*) "ws://127.0.0.1:2586/$1" [P,L]
669
669
670
670
# Redirect HTTP to HTTPS, but only for GET topic addresses, since we want
671
- # it to work with curl without the annoying https:// prefix
672
- RewriteCond %{REQUEST_METHOD} GET
673
- RewriteRule ^/([-_A-Za-z0-9]{0,64})$ https://%{SERVER_NAME}/$1 [R,L]
671
+ # it to work with curl without the annoying https:// prefix (requires "a2enmod alias")
672
+ <If "%{REQUEST_METHOD} == 'GET'">
673
+ RedirectMatch permanent "^/([-_A-Za-z0-9]{0,64})$" "https://%{SERVER_NAME}/$1"
674
+ </If>
675
+
674
676
</VirtualHost>
675
677
676
678
<VirtualHost *:443>
@@ -681,23 +683,16 @@ or the root domain:
681
683
SSLCertificateKeyFile /etc/letsencrypt/live/ntfy.sh/privkey.pem
682
684
Include /etc/letsencrypt/options-ssl-apache.conf
683
685
684
- # Proxy connections to ntfy (requires "a2enmod proxy")
685
- ProxyPass / http://127.0.0.1:2586/
686
+ # Proxy connections to ntfy (requires "a2enmod proxy proxy_http ")
687
+ ProxyPass / http://127.0.0.1:2586/ upgrade=websocket
686
688
ProxyPassReverse / http://127.0.0.1:2586/
687
689
688
690
SetEnv proxy-nokeepalive 1
689
691
SetEnv proxy-sendchunked 1
690
692
691
693
# Higher than the max message size of 4096 bytes
692
694
LimitRequestBody 102400
693
-
694
- # Enable mod_rewrite (requires "a2enmod rewrite")
695
- RewriteEngine on
696
-
697
- # WebSockets support (requires "a2enmod rewrite proxy_wstunnel")
698
- RewriteCond %{HTTP:Upgrade} websocket [NC]
699
- RewriteCond %{HTTP:Connection} upgrade [NC]
700
- RewriteRule ^/?(.*) "ws://127.0.0.1:2586/$1" [P,L]
695
+
701
696
</VirtualHost>
702
697
```
703
698
0 commit comments