名称: npm-proxy
描述: 管理 Nginx Proxy Manager (NPM) 的主机、证书和访问列表。适用于用户需要添加新域名、将域名指向服务器/端口、启用 SSL 或检查代理主机状态的场景。
通过 REST API 管理 Nginx Proxy Manager (NPM)。
设置以下环境变量:
- NPM_URL: NPM 实例的 URL(例如 https://npm.example.com)
- NPM_EMAIL: NPM 管理员邮箱
- NPM_PASSWORD: NPM 管理员密码
# 列出所有代理主机
python scripts/npm_client.py hosts
# 获取特定主机的详细信息
python scripts/npm_client.py host <host_id>
# 启用/禁用主机
python scripts/npm_client.py enable <host_id>
python scripts/npm_client.py disable <host_id>
# 删除主机
python scripts/npm_client.py delete <host_id>
# 列出证书
python scripts/npm_client.py certs
要添加新主机,请直接使用 curl(当前脚本功能较为基础)。
向 POST /api/nginx/proxy-hosts 发送请求的示例负载:
{
"domain_names": ["sub.example.com"],
"forward_scheme": "http",
"forward_host": "192.168.1.10",
"forward_port": 8080,
"access_list_id": 0,
"certificate_id": 0,
"ssl_forced": false,
"meta": {
"letsencrypt_email": "",
"letsencrypt_agree": false,
"dns_challenge": false
},
"advanced_config": "",
"locations": [],
"block_exploits": true,
"caching_enabled": false,
"allow_websocket_upgrade": true,
"http2_support": true,
"hsts_enabled": false,
"hsts_subdomains": false
}
certs 命令列出证书,查看是否已存在所需证书。certificate_id 并启用 ssl_forced: true。