This is a Python script that use a domain to update the IP address in the NPM access-list.
Follow the steps below and run the script. A new column called domain will be added to the database and a file called npm_domain_check.json will be created in the same path where the script is located.
Ensure you are created the access-list first in NPM with ip and a network /32 that you wand change dynamically, then add a domain to an IP address in the json file:
// Example
{
"74.125.29.139": "google.com",
"140.82.121.4": "github.com"
}- Use a container_name in docker-compose or run command:
services:
app:
container_name: npm # For example- Copy
npm_domain_check.pyscript to/usr/local/bin/npm_domain_check.pyin your docker-machine
Note: not into container!
sudo curl -o "/usr/local/bin/npm_domain_check.py" "https://raw.githubusercontent.com/AmaneSwiss/NPM-DomainCheckScript/refs/heads/main/scripts/npm_domain_check.py"
sudo chmod +x /usr/local/bin/npm_domain_check.py- Change line 10 in
npm_domain_check.pyfrom CONTAINER_NAME to container_name from step 1
Note: use nano for example
# Your 'Nginx Proxy Manager' container name here
CONTAINER_NAME = "npm" # <- Change here- Add a cron job to run the script continuously
sudo crontab -efor edit the root cron table an add:
# NPM domain-check
* * * * * /usr/local/bin/npm_domain_check.pyThis will run the script every minute. You can change * * * * * to */5 * * * * to run it every 5 minutes for example.
Help for cronjobs can you find here
- Remove the cron job with
sudo crontab -eand delete the added lines.
# NPM domain-check # <- remove
* * * * * /usr/local/bin/npm_domain_check.py # <- remove- Remove the script and config file
rm -f /usr/local/bin/npm_domain_check*- Remove the created
domaincolumn using a Python script as well:
scripts/remove_domain_column.py
sudo curl -o "/tmp/remove_domain_column.py" "https://raw.githubusercontent.com/AmaneSwiss/NPM-DomainCheckScript/refs/heads/main/scripts/remove_domain_column.py"
sudo chmod +x /tmp/remove_domain_column.py- Change line 7 in
remove_domain_column.pyfrom CONTAINER_NAME to container_name
# Your 'Nginx Proxy Manager' container name here
CONTAINER_NAME = "npm" # <- Change here- Run script
/tmp/remove_domain_column.py