nginx-proxy-api is a REST API service for automating Nginx reverse proxy configuration, managing SSL certificates via certbot, and handling DNS records through Cloudflare.
It allows automatic provisioning of HTTPS proxying for subdomains or custom domains pointing to specified backend targets.
-
Add new proxy
- Creates
ADNS record in Cloudflare pointing to your node IP - Verifies or issues SSL certificates via
certbot - Generates and enables Nginx site configuration
- Reloads Nginx automatically
- Creates
-
Remove proxy
- Deletes Nginx config and symlink
- Removes DNS record from Cloudflare (if applicable)
- Deletes SSL certificate via
certbot
-
Secure API
- Access control by allowed IPs
- Token-based authentication
- CORS configuration for specific origins
- Graceful shutdown and structured logging with
zap
We provide a convenient installer script that automates binary download, configuration setup, and systemd service creation.
⚠️ Warning! Read the configuration and template setup below before running the installer.
curl -fsSL https://raw.githubusercontent.com/d1manpro/nginx-proxy-api/refs/heads/main/scripts/install-linux-amd64.sh | sudo bashThe installer will:
-
Download the latest binary from GitHub Releases
-
Create
/usr/local/bin/npapiand make it executable -
Set up configuration directory
/etc/npapiwith:config.ymltemplate.conffor Nginx reverse proxy
-
Create log file
/var/log/npapi.log -
Install and enable systemd service
npapi
After installation, the service will start automatically.
After installation, edit /etc/npapi/config.yml to set:
cloudflare.token— your Cloudflare API tokencloudflare.node_ip— the IP address for new DNS recordscloudflare.domains— map of domain names to Cloudflare zone IDsemail— your Lets Encrypt email address for CertBot
You can also customize the Nginx template in /etc/npapi/template.conf.
Use the generated API token (printed at the end of installation) for authentication:
curl -X GET http://localhost:8080/test \
-H "Authorization: Bearer <your_token>"Uses zap with a human-readable console encoder and timestamps in YYYY.MM.DD HH:MM:SS.mmm format.
Saves logs into /var/log/npapi.log
-
Nginx installed and configured with:
/etc/nginx/sites-available/ /etc/nginx/sites-enabled/ -
certbot(with nginx and dns-cloudflare plugins) -
Valid Cloudflare API token with
Zone.DNSpermissions
| Method | Path | Description | Auth Required |
|---|---|---|---|
| POST | /proxy |
Add proxy config | ✅ |
| DELETE | /proxy |
Remove proxy config | ✅ |
| GET | /test |
Health check | ✅ |
Add proxy
curl -X POST https://api.example.com/add-proxy \
-H "Authorization: Bearer your_api_token" \
-d '{"domain": "sub.example.com", "target": "node.example.com:8800"}'Remove proxy
curl -X POST https://api.example.com/remove-proxy \
-H "Authorization: Bearer your_api_token" \
-d '{"domain": "sub.example.com"}'When receiving SIGINT or SIGTERM, the service:
- Stops the HTTP server gracefully
- Closes all open connections
- Writes shutdown messages to the log
Developed by @d1manpro. Licensed under MIT License.