Sign inSign up

alexmikhalochkin/do-firewall-updater

By alexmikhalochkin

•Updated over 2 years ago

Automatic Firewall Updater for DigitalOcean with Target Server Monitoring

Image
Networking
Security
Internet of things
0

480

alexmikhalochkin/do-firewall-updater repository overview

⁠Automatic Firewall Updater for DigitalOcean with Target Server Monitoring

Description:

This Docker image provides a robust solution for automatically maintaining firewall rules on your DigitalOcean droplets. It leverages the doctl CLI tool and server reachability checks to ensure your firewall is always up-to-date with your current IP address.

Key Features:

  • Automated Updates: Continuously monitors a target server's accessibility at configurable intervals (defined by the CHECK_INTERVAL_SECONDS environment variable).
  • Dynamic IP Management: Automatically updates the inbound firewall rule for port 1883 (MQTT protocol by default) with your droplet's current public IP address.
  • DigitalOcean Integration: Seamlessly interacts with the DigitalOcean API using the doctl CLI tool.
  • Customizable Monitoring: Allows you to adjust the CHECK_INTERVAL_SECONDS environment variable to tailor the monitoring frequency to your specific needs.

Benefits:

  • Enhanced Security: Eliminates the risk of outdated firewall rules leaving your server vulnerable by automatically updating them with your dynamic IP.
  • Simplified Management: Automates the firewall update process, saving you time and effort.
  • Reduced Downtime: Ensures uninterrupted communication by keeping the firewall in sync with your current IP address.
  • Improved Efficiency: Leverages the power of Docker containers for streamlined deployment and maintenance.

How to Use:

  1. Set Environment Variables:

    • DIGITAL_OCEAN_TOKEN: Your DigitalOcean API access token (obtainable from the DigitalOcean control panel).
    • DIGITAL_OCEAN_FIREWALL_ID: The ID of the firewall you want to update.
    • TARGET_HOST: The hostname or IP address of the target server to monitor.
    • TARGET_PORT (optional): The port on the target server used for communication (defaults to 1883 for MQTT).
    • CHECK_INTERVAL_SECONDS (optional): The frequency (in seconds) at which to check the target server's reachability (defaults to a reasonable value).
  2. Build the Image (Optional):

    docker build -t your_username/firewall-updater .
    
  3. Run the Container:

    docker run -d --env-file .env your_username/firewall-updater
    

    Replace your_username/firewall-updater with the actual image name you built or used from Docker Hub. You can also create a .env file to store your environment variables for easier management.

Additional Notes:

  • For enhanced security, consider storing your DigitalOcean API token in a secure environment variable store instead of directly in the Dockerfile.
  • Double-check the firewall rule configuration (inbound protocol, port number) to ensure it aligns with your application's communication requirements.
  • Feel free to adjust the CHECK_INTERVAL_SECONDS environment variable to strike a balance between efficient monitoring and minimizing API calls.

Tag summary

Content type

Image

Digest

sha256:00ca5956a…

Size

23.8 MB

Last updated

over 2 years ago

docker pull alexmikhalochkin/do-firewall-updater