This is a lightweight HTTP service designed to integrate with Caddy for TLS automation. It provides a simple endpoint to check if a given domain is allowed for certificate issuance.
No external dependencies are required for this basic setup. The service reads a list of allowed domains from a file and dynamically updates the list without restarting the server.
Caddy documentation: Registered domains (on-demand)
- Query endpoint for domain validation.
- Dynamic domain management through a file (
domains.txt). - Logs requests and system activity.
- Lightweight and easy to configure.
- Domain Validation: The service checks whether a domain is allowed by consulting a list of domains stored in
domains.txt. - Endpoint: The service exposes an HTTP GET endpoint
/check_domainfor domain validation. - Dynamic Updates: The service monitors the
domains.txtfile for changes every minute.
- Python 3.7 or higher
- Clone this repository.
- Navigate to the project directory.
- Install any required dependencies (none required for this basic setup).
- Create an empty
domains.txtfile in the project directory:touch domains.txt
- Start the server:
python3 server.py
- The server runs on
http://127.0.0.1:8008by default.
- Use the
/check_domainendpoint to validate a domain. - Example request:
curl "http://127.0.0.1:8008/check_domain?domain=example.com" - Response:
- Allowed:
{"domain": "example.com", "allowed": true} - Not Allowed:
{"domain": "example.com", "allowed": false}
- Allowed:
- Add or remove domains in the
domains.txtfile. - Changes will be reflected within a minute without restarting the server.
| Parameter | Default Value | Description |
|---|---|---|
DOMAINS_FILE |
domains.txt |
Path to the domains file. |
LOG_FILE |
domain_checker.log |
Path to the log file (optional). |
| Server Address | 127.0.0.1:8008 |
IP and port for the HTTP server. |
Logs system activity and domain queries to the console. You can configure it to log to a file by uncommenting the FileHandler line in the logging setup.
To set up the service to run automatically using systemd, follow these steps:
-
Create a new service file:
sudo nano /etc/systemd/system/caddy-domain-checker.service
-
Add the following content to the file:
[Unit] Description=Caddy Domain Checker Service After=network.target [Service] ExecStart=/usr/bin/python3 /mnt/data/www/domain_checker/app.py WorkingDirectory=/mnt/data/www/domain_checker Restart=always RestartSec=5 User=www-data Group=www-data StandardOutput=journal StandardError=journal [Install] WantedBy=multi-user.target
-
Save and close the file.
-
Reload the
systemddaemon to recognize the new service:sudo systemctl daemon-reload
-
Enable the service to start on boot:
sudo systemctl enable caddy-domain-checker -
Start the service:
sudo systemctl start caddy-domain-checker
-
Check the service status to ensure it is running:
sudo systemctl status caddy-domain-checker
- Use
curlor any HTTP client to interact with the service. - Ensure the
domains.txtfile is updated correctly for testing.
- Stop the server gracefully with
Ctrl+C.
This project is licensed under the MIT License. See the LICENSE file for details.
Note: This service is intended to work seamlessly with Caddy's TLS automation and is not designed for general-purpose use without modifications.