Skip to content

Commit

Permalink
Merge branch 'main' of github.com:binwiederhier/ntfy
Browse files Browse the repository at this point in the history
  • Loading branch information
binwiederhier committed Aug 17, 2023
2 parents 3e3b556 + 723daf9 commit c31bce1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
41 changes: 18 additions & 23 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ Here are a few working sample configs:
attachment-cache-dir: "/var/cache/ntfy/attachments"
```

=== "server.yml (behind proxy, with cache + attachments)"
``` yaml
base-url: "http://ntfy.example.com"
listen-http: ":2586"
cache-file: "/var/cache/ntfy/cache.db"
attachment-cache-dir: "/var/cache/ntfy/attachments"
```

=== "server.yml (ntfy.sh config)"
``` yaml
# All the things: Behind a proxy, Firebase, cache, attachments,
Expand Down Expand Up @@ -649,28 +657,22 @@ or the root domain:
<VirtualHost *:80>
ServerName ntfy.sh

# Proxy connections to ntfy (requires "a2enmod proxy")
ProxyPass / http://127.0.0.1:2586/
# Proxy connections to ntfy (requires "a2enmod proxy proxy_http")
ProxyPass / http://127.0.0.1:2586/ upgrade=websocket
ProxyPassReverse / http://127.0.0.1:2586/

SetEnv proxy-nokeepalive 1
SetEnv proxy-sendchunked 1

# Higher than the max message size of 4096 bytes
LimitRequestBody 102400

# Enable mod_rewrite (requires "a2enmod rewrite")
RewriteEngine on

# WebSockets support (requires "a2enmod rewrite proxy_wstunnel")
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:2586/$1" [P,L]
# Redirect HTTP to HTTPS, but only for GET topic addresses, since we want
# it to work with curl without the annoying https:// prefix
RewriteCond %{REQUEST_METHOD} GET
RewriteRule ^/([-_A-Za-z0-9]{0,64})$ https://%{SERVER_NAME}/$1 [R,L]
# it to work with curl without the annoying https:// prefix (requires "a2enmod alias")
<If "%{REQUEST_METHOD} == 'GET'">
RedirectMatch permanent "^/([-_A-Za-z0-9]{0,64})$" "https://%{SERVER_NAME}/$1"
</If>

</VirtualHost>

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

# Proxy connections to ntfy (requires "a2enmod proxy")
ProxyPass / http://127.0.0.1:2586/
# Proxy connections to ntfy (requires "a2enmod proxy proxy_http")
ProxyPass / http://127.0.0.1:2586/ upgrade=websocket
ProxyPassReverse / http://127.0.0.1:2586/

SetEnv proxy-nokeepalive 1
SetEnv proxy-sendchunked 1

# Higher than the max message size of 4096 bytes
LimitRequestBody 102400

# Enable mod_rewrite (requires "a2enmod rewrite")
RewriteEngine on

# WebSockets support (requires "a2enmod rewrite proxy_wstunnel")
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:2586/$1" [P,L]

</VirtualHost>
```

Expand Down
4 changes: 4 additions & 0 deletions server/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
# - "field -> level" to match any value, e.g. "time_taken_ms -> debug"
# Warning: Using log-level-overrides has a performance penalty. Only use it for temporary debugging.
#
# Check your permissions:
# If you are running ntfy with systemd, make sure this log file is owned by the
# ntfy user and group by running: chown ntfy.ntfy <filename>.
#
# Example (good for production):
# log-level: info
# log-format: json
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/notificationUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const formatMessage = (m) => {
};

const imageRegex = /\.(png|jpe?g|gif|webp)$/i;
const isImage = (attachment) => {
export const isImage = (attachment) => {
if (!attachment) return false;

// if there's a type, only take that into account
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/Notifications.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { useOutletContext } from "react-router-dom";
import { useRemark } from "react-remark";
import styled from "@emotion/styled";
import { formatBytes, formatShortDateTime, maybeActionErrors, openUrl, shortUrl, topicShortUrl, unmatchedTags } from "../app/utils";
import { formatMessage, formatTitle } from "../app/notificationUtils";
import { formatMessage, formatTitle, isImage } from "../app/notificationUtils";
import { LightboxBackdrop, Paragraph, VerticallyCenteredContainer } from "./styles";
import subscriptionManager from "../app/SubscriptionManager";
import priority1 from "../img/priority-1.svg";
Expand Down Expand Up @@ -346,7 +346,7 @@ const Attachment = (props) => {
const { attachment } = props;
const expired = attachment.expires && attachment.expires < Date.now() / 1000;
const expires = attachment.expires && attachment.expires > Date.now() / 1000;
const displayableImage = !expired && attachment.type && attachment.type.startsWith("image/");
const displayableImage = !expired && isImage(attachment);

// Unexpired image
if (displayableImage) {
Expand Down

0 comments on commit c31bce1

Please sign in to comment.