Skip to content

Commit 723daf9

Browse files
Merge pull request #819 from nisbet-hubbard/patch-1
Tweak httpd config to use less resources
2 parents 7d20238 + 4e9eeb1 commit 723daf9

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

docs/config.md

+18-23
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ Here are a few working sample configs:
4444
attachment-cache-dir: "/var/cache/ntfy/attachments"
4545
```
4646

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+
4755
=== "server.yml (ntfy.sh config)"
4856
``` yaml
4957
# All the things: Behind a proxy, Firebase, cache, attachments,
@@ -649,28 +657,22 @@ or the root domain:
649657
<VirtualHost *:80>
650658
ServerName ntfy.sh
651659

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
654662
ProxyPassReverse / http://127.0.0.1:2586/
655663

656664
SetEnv proxy-nokeepalive 1
657665
SetEnv proxy-sendchunked 1
658666

659667
# Higher than the max message size of 4096 bytes
660668
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]
669669
670670
# 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+
674676
</VirtualHost>
675677

676678
<VirtualHost *:443>
@@ -681,23 +683,16 @@ or the root domain:
681683
SSLCertificateKeyFile /etc/letsencrypt/live/ntfy.sh/privkey.pem
682684
Include /etc/letsencrypt/options-ssl-apache.conf
683685

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
686688
ProxyPassReverse / http://127.0.0.1:2586/
687689

688690
SetEnv proxy-nokeepalive 1
689691
SetEnv proxy-sendchunked 1
690692

691693
# Higher than the max message size of 4096 bytes
692694
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+
701696
</VirtualHost>
702697
```
703698

server/server.yml

+4
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@
342342
# - "field -> level" to match any value, e.g. "time_taken_ms -> debug"
343343
# Warning: Using log-level-overrides has a performance penalty. Only use it for temporary debugging.
344344
#
345+
# Check your permissions:
346+
# If you are running ntfy with systemd, make sure this log file is owned by the
347+
# ntfy user and group by running: chown ntfy.ntfy <filename>.
348+
#
345349
# Example (good for production):
346350
# log-level: info
347351
# log-format: json

0 commit comments

Comments
 (0)