Sign inSign up

1linkpro/npm

By 1linkpro

Updated 11 months ago

Npm synchronization containers to HA

Image
0

2.8K

1linkpro/npm repository overview

Custom Nginx Proxy Manager (NPM) Image

This repository contains a custom image built on top of the official jc21/nginx-proxy-manager, with additional services and configurations to meet advanced deployment requirements.

Base Image

  • Image: jc21/nginx-proxy-manager:latest
  • Platform: --platform=linux/amd64

Purpose

This custom image extends the functionality of Nginx Proxy Manager by introducing:

  1. Redis: For synchronization across multiple containers in clustered setups.
  2. Rsyslog: For centralized log collection and forwarding to external log servers.

Key Features and Customizations

1. Redis Service
  • Purpose:
    • Synchronizes configurations and runtime information across multiple NPM containers in a clustered setup.
  • Configuration:
    • Configurable via environment variables:
      • REDIS_HOST
      • REDIS_PORT
      • REDIS_PASSWORD
2. Rsyslog Service
  • Purpose:
    • Centralizes and forwards logs (access and error) from Nginx Proxy Manager to a dedicated log server.
    • Supports custom log formats compatible with tools such as GoAccess.
  • Capabilities:
    • Writes logs locally and forwards them to external servers.
    • Outputs logs in "Combined Log Format" (CLF) for analytics tools.
3. Customizations
  • Dynamic Logging:
    • Dynamically captures and writes logs from multiple proxies managed by NPM.
  • Environment Variables:
    • Fully supports initialization via Docker Compose or Swarm:
      • Redis: REDIS_HOST, REDIS_PORT, REDIS_PASSWORD
      • Rsyslog: RSYSLOG_SERVER_IP, 514

Included Services and Utilities

  1. Redis CLI:
    • Provides local access for administration and testing of Redis configurations.
  2. Rsyslog Daemon:
    • Captures logs and forwards them to the specified log server.
  3. Dynamic Log Formatting:
    • Formats logs dynamically to match analytics tools' requirements, such as GoAccess.

Usage

Docker Compose Example
version: '3.7'
services:
  npm:
    image: 1linkpro/npm:latest
    environment:
      INITIAL_ADMIN_EMAIL: [email protected]
      INITIAL_ADMIN_PASSWORD: strongpassword
      REDIS_HOST: redis-nginx
      REDIS_PORT: 6379
      RSYSLOG_SERVER_IP: rsyslog
    volumes:
      - /mnt/docker_volumes/npm_data:/data #Must be a Shared volume
      - /mnt/docker_volumes/npm_certificates:/etc/letsencrypt #Must be a Shared volume
      - npm_logs:/data/logs #Volume Local
    ports:
      - "80:80"
      - "443:443"
      - "81:81"
    networks:
      - public

  redis-nginx:
    image: redis:alpine
    networks:
      - public

  rsyslog:
    image: rwestergren/simple-docker-rsyslog:latest
    volumes:
      - /mnt/docker_volumes/nginx-logs.conf:/etc/rsyslog.d/nginx-logs.conf #Config to parser logs, must be a Shared volume
      - /mnt/docker_volumes/nginx_logs:/var/tmp #Must be a Shared volume
    restart: unless-stopped
    networks:
      - public
volumes:
  npm_logs:
    driver: local
    name: npm_logs

networks:
  public:
    external: true
File nginx-logs.conf
# Ignore HealthCheck Load Balancer
if $msg contains "HCLB-HealthCheck" then stop

# Template to parser original log
template(name="RawLogFormat" type="string" string="%msg:2:$%\n")

# Template to save logs
template(name="AccessFile" type="string" string="/var/tmp/proxy-host-1_access.log")
template(name="ErrorFile" type="string" string="/var/tmp/proxy-host-1_error.log")

# Access Log
if $programname startswith 'proxy-host-access' then ?AccessFile;RawLogFormat

# Error log
if $programname startswith 'proxy-host-error' then ?ErrorFile;RawLogFormat

Benefits

  1. Centralized Logging:

    • Captures access and error logs from NPM-managed proxies and forwards them to a centralized log server.
  2. Scalable Synchronization:

    • Redis ensures synchronization across multiple containers in a clustered setup.
  3. Real-Time Analytics:

    • Fully compatible with tools like GoAccess, enabling real-time visualization and analysis of logs.
  4. High Performance:

    • Optimized for large-scale deployments using load balancers and clustered setups.

Contributions

Contributions are welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.


License

This project is licensed under the MIT License.

Tag summary

Content type

Image

Digest

sha256:a24d07d37

Size

361.1 MB

Last updated

11 months ago

docker pull 1linkpro/npm