1.正常搭建(无验证)

2.添加用户验证

cd /opt/1panel/apps/ntfy./ntfy
# 1Panel-ntfy-52WC___----->>>>>容器名称
# 1. 备份原配置
sudo cp ./data/ntfy/server.yml ./data/ntfy/server.yml.bak.$(date +%Y%m%d%H%M%S)

# 2. 写入新配置(记得修改域名)
sudo tee ./data/ntfy/server.yml > /dev/null << 'EOF'
# ntfy server config file
base-url: https:/网址  # 修改为你的实际域名
auth-file: /var/cache/ntfy/auth.db
auth-default-access: deny-all
cache-file: /var/cache/ntfy/cache.db
cache-duration: "12h"
log-level: info
EOF

# 3. 修复权限
sudo docker stop 1Panel-ntfy-52WC
sudo rm -f ./data/cache/ntfy/auth.db
sudo chown -R 1000:1000 ./data/cache/ntfy/ ./data/ntfy/

# 4. 重启并创建用户
sudo docker start 1Panel-ntfy-52WC
sleep 15
sudo docker exec -it 1Panel-ntfy-52WC ntfy user add --role=admin remuxo_用户名
# 按提示输入密码

创建之后重启,发送消息就需要验证了

curl -u remuxo_用户名:你的密码 -d "测试消息" https://网址/mytopic