### Test Nginx Proxy with a Domain (Bash) Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/README.md This command initiates a test of the nginx-proxy setup by running a test script with a specified domain name. Ensure your DNS is configured to point to your server. ```bash ./test.sh your.domain.com ``` -------------------------------- ### Execute Fresh Start Script for Nginx Proxy Automation Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/upgrade-guide.md This command navigates to the 'bin' directory and executes the 'fresh-start.sh' script. This script is responsible for setting up new configurations for the Nginx proxy, potentially including new network configurations. An expected error related to port 80 binding might occur if the current Nginx proxy is already using it. ```bash cd bin ./fresh-start.sh ``` -------------------------------- ### Setup Configuration Directories and Permissions (Shell) Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/HOWTO-Synology.md This command sequence sets up the necessary directories for Nginx proxy configuration and persistent files, such as certificates and virtual host configurations. It also assigns group ownership and read/write/execute permissions to the 'data' directory and its contents, ensuring proper access for the application. ```shell mkdir -p data/certs mkdir data/htpasswd mkdir data/conf.d mkdir data/vhost.d mkdir data/html chgrp -R 101 data chmod -R g+rwx data ``` -------------------------------- ### Revert to Previous Nginx Proxy Configuration Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/upgrade-guide.md This command provides a quick way to revert to the previous Nginx proxy setup. It stops the current services and then starts the services defined in 'docker-compose-old.yml' using the '.env-old' environment file, effectively rolling back the upgrade. ```bash docker-compose down && docker-compose --file docker-compose-old.yml --env-file .env-old up -d ``` -------------------------------- ### Install and Setup NGINX Proxy Automation Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt Shell script to clone the repository and initialize the NGINX proxy environment. It can be run with automated options or interactively. Requires Git and Docker. ```bash # Clone repository with required submodules git clone --recurse-submodules https://github.com/evertramos/nginx-proxy-automation.git proxy # Navigate to bin directory and run fresh-start with automated options cd proxy/bin ./fresh-start.sh --yes --skip-docker-image-check -e your_email@domain.com # Interactive mode (prompts for all configuration options) ./fresh-start.sh # With custom options ./fresh-start.sh \ -e admin@example.com \ --proxy-name=my-proxy \ --letsencrypt-name=my-letsencrypt \ --docker-gen-name=my-docker-gen \ --network-name=webproxy \ --data-files-location=/srv/nginx-data \ --ip-address=0.0.0.0 \ --yes ``` -------------------------------- ### Restart Nginx Proxy Services with New Configuration Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/upgrade-guide.md This command first stops the old Nginx proxy services using 'docker-compose-old.yml' and then starts the new services with the updated configuration using 'docker-compose up -d'. This is done in a single line to minimize downtime during the upgrade process. ```bash docker-compose --file docker-compose-old.yml down && docker-compose up -d ``` -------------------------------- ### Testing Nginx Proxy Functionality Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt Provides bash scripts and manual commands for testing the Nginx proxy setup. Includes tests for HTTP and SSL configurations, as well as commands to start, stop, and verify proxy behavior. ```bash # Test HTTP proxy (no SSL) cd proxy/bin ./test.sh your.domain.com # Test with SSL certificate provisioning ./ssl_test.sh your.domain.com # Stop and clean up test container ./stop.sh # Manual testing docker run -dit \ -e VIRTUAL_HOST=test.example.com \ --network=proxy \ --rm \ --name test-web \ httpd:alpine # Verify configuration curl -I http://test.example.com # Clean up docker stop test-web ``` -------------------------------- ### Configure Cloudflare DNS-01 Integration (Bash) Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt This guide details setting up Cloudflare DNS-01 ACME challenges for SSL certificates when HTTP-01 challenges are not feasible. It involves creating a Cloudflare API token with appropriate permissions, adding the token to the `.env` file, uncommenting DNS-01 configurations in `docker-compose.yml`, and restarting the proxy. ```bash # 1. Create Cloudflare API Token with Zone DNS permissions # Go to: Cloudflare Dashboard > Profile > API Tokens # Use "Edit zone DNS" template or create custom token # Restrict to specific zones and source IP addresses # 2. Add token to .env file echo 'CLOUDFLARE_DNS_TOKEN=your_api_token_here' >> .env # 3. Uncomment DNS-01 configuration in docker-compose.yml # In nginx-proxy-automation-letsencrypt service: # environment: # ACME_CHALLENGE: "DNS-01" # ACMESH_DNS_API_CONFIG: |- # DNS_API: dns_cf # CF_Token: "${CLOUDFLARE_DNS_TOKEN}" # 4. Restart the proxy docker compose down && docker compose up -d ``` -------------------------------- ### Configure Virtual Port in Docker Compose (YAML) Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/README.md Example of setting the VIRTUAL_PORT environment variable within a docker-compose.yml file to ensure the service container's port is correctly proxied by nginx-proxy. ```yaml parity image: parity/parity:v1.8.9 [...] environment: [...] VIRTUAL_PORT: 8545 ``` -------------------------------- ### Configure Basic Authentication for Virtual Hosts (Bash) Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt This snippet demonstrates how to protect virtual hosts using HTTP basic authentication by creating htpasswd files. It involves setting environment variables, creating the htpasswd file, adding users with passwords using openssl, and reloading Nginx. Alternatively, the `htpasswd` command can be used after installing `apache2-utils`. ```bash # Set variables NGINX_FILES_PATH=/srv/nginx-data # or ./data if using defaults VIRTUAL_HOST=admin.example.com # Create htpasswd file with username sudo sh -c "echo -n 'admin:' >> ${NGINX_FILES_PATH}/htpasswd/${VIRTUAL_HOST}" # Add password (you'll be prompted) sudo sh -c "openssl passwd -apr1 >> ${NGINX_FILES_PATH}/htpasswd/${VIRTUAL_HOST}" # Add additional users sudo sh -c "echo -n 'user2:' >> ${NGINX_FILES_PATH}/htpasswd/${VIRTUAL_HOST}" sudo sh -c "openssl passwd -apr1 >> ${NGINX_FILES_PATH}/htpasswd/${VIRTUAL_HOST}" # Reload nginx to apply changes (no downtime) docker exec -it nginx-proxy-automation-web nginx -s reload # Alternatively, using htpasswd command sudo apt-get install apache2-utils sudo htpasswd -c ${NGINX_FILES_PATH}/htpasswd/${VIRTUAL_HOST} admin sudo htpasswd ${NGINX_FILES_PATH}/htpasswd/${VIRTUAL_HOST} user2 ``` -------------------------------- ### NGINX Proxy Automation Docker Compose Configuration Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt Defines the core services for the NGINX proxy automation setup using Docker Compose. Includes the NGINX web server, docker-gen for dynamic configuration, and acme-companion for SSL certificate management. ```yaml services: nginx-proxy: container_name: ${PROXY_NAME} image: ${PROXY_IMAGE_VERSION} restart: always ports: - "${PORT_HTTP}:80" - "${PORT_HTTPS}:443" volumes: - "${DATA_FILES_LOCATION}/conf.d:/etc/nginx/conf.d" - "${DATA_FILES_LOCATION}/html:/usr/share/nginx/html" - "${DATA_FILES_LOCATION}/certs:/etc/nginx/certs" - "/var/run/docker.sock:/tmp/docker.sock:ro" networks: - ${NETWORK_NAME} docker-gen: container_name: ${DOCKER_GEN_NAME} image: ${DOCKER_GEN_IMAGE_VERSION} restart: always volumes: - "/var/run/docker.sock:/tmp/docker.sock:ro" - "${DATA_FILES_LOCATION}/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro" command: -notify-sighup ${PROXY_NAME} -watch -wait-timeout 20000 -default-event-timeout 20000 -template "/etc/docker-gen/templates/nginx.tmpl:/etc/nginx/conf.d/default.conf" networks: - ${NETWORK_NAME} letsencrypt-nginx-proxy-companion: container_name: ${LETSENCRYPT_NAME} image: ${LETSENCRYPT_IMAGE_VERSION} restart: always volumes: - "${DATA_FILES_LOCATION}/certs:/etc/letsencrypt" - "/var/run/docker.sock:/var/run/docker.sock:ro" networks: - ${NETWORK_NAME} networks: ${NETWORK_NAME}: external: true ``` -------------------------------- ### Docker Compose Configuration for Nginx Proxy Automation Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt Defines the services for Nginx, Docker-gen, and Let's Encrypt companion within a Docker Compose setup. It configures volumes, ports, and environment variables for each service, including network configurations. ```yaml services: nginx-proxy-automation-web: image: nginx:${NGINX_IMAGE_VERSION:-stable-alpine} labels: com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true" container_name: ${NGINX_WEB_SEVICE_NAME:-nginx-proxy-automation-web} restart: always ports: - "${IPv4:-0.0.0.0}:${DOCKER_HTTP_:-80}:80" - "${IPv4:-0.0.0.0}:${DOCKER_HTTPS:-443}:443" environment: SSL_POLICY: ${SSL_POLICY:-Mozilla-Intermediate} volumes: - ${NGINX_FILES_PATH:-./data}/conf.d:/etc/nginx/conf.d - ${NGINX_FILES_PATH:-./data}/vhost.d:/etc/nginx/vhost.d - ${NGINX_FILES_PATH:-./data}/html:/usr/share/nginx/html - ${NGINX_FILES_PATH:-./data}/certs:/etc/nginx/certs:ro - ${NGINX_FILES_PATH:-./data}/htpasswd:/etc/nginx/htpasswd:ro nginx-proxy-automation-gen: image: nginxproxy/docker-gen:${DOCKER_GEN_IMAGE_VERSION:-0.7.7} command: -notify-sighup ${NGINX_WEB_SEVICE_NAME:-nginx-proxy-automation-web} -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf container_name: ${DOCKER_GEN_SEVICE_NAME:-nginx-proxy-automation-gen} restart: always volumes: - ${NGINX_FILES_PATH:-./data}/conf.d:/etc/nginx/conf.d - ${NGINX_FILES_PATH:-./data}/vhost.d:/etc/nginx/vhost.d - ${DOCKER_HOST_ROOTLESS_PATH:-/var/run/docker.sock}:/tmp/docker.sock:ro - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro nginx-proxy-automation-letsencrypt: image: nginxproxy/acme-companion:${NGINX_PROXY_COMPANION_IMAGE_VERSION:-2.1} container_name: ${LETS_ENCRYPT_SEVICE_NAME:-nginx-proxy-automation-letsencrypt} restart: always volumes: - ${NGINX_FILES_PATH:-./data}/certs:/etc/nginx/certs:rw - ${NGINX_FILES_PATH:-./data}/acme.sh:/etc/acme.sh - ${DOCKER_HOST_ROOTLESS_PATH:-/var/run/docker.sock}:/var/run/docker.sock:ro environment: NGINX_DOCKER_GEN_CONTAINER: ${DOCKER_GEN_SEVICE_NAME:-nginx-proxy-automation-gen} NGINX_PROXY_CONTAINER: ${NGINX_WEB_SEVICE_NAME:-nginx-proxy-automation-web} DEFAULT_EMAIL: ${DEFAULT_EMAIL:-mail@yourdomain.tld} networks: default: external: true name: ${NETWORK:-proxy} ``` -------------------------------- ### Manage Nginx Proxy Reloading and Restarting (Bash) Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt This section provides essential commands for managing the Nginx proxy containers. It includes instructions for reloading Nginx configuration without downtime, restarting individual containers or all proxy services using `docker restart` or `docker compose restart`, performing a full stop and start, viewing logs, and checking container status. ```bash # Reload nginx configuration (no downtime) docker exec -it nginx-proxy-automation-web nginx -s reload # Restart specific container docker restart nginx-proxy-automation-web # Restart all proxy services cd /path/to/proxy docker compose restart # Full stop and start docker compose down docker compose up -d # View logs docker logs -f nginx-proxy-automation-web docker logs -f nginx-proxy-automation-letsencrypt docker logs -f nginx-proxy-automation-gen # Check container status docker compose ps ``` -------------------------------- ### Upgrade Nginx Proxy from v0.4 to v0.5 (Bash) Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt This guide outlines the steps for upgrading the Nginx proxy from version 0.4 to 0.5. The process involves backing up the current configuration files (`docker-compose.yml` and `.env`), resetting the local repository to the latest state, pulling the most recent changes from the master branch, and checking out the master branch. ```bash # 1. Backup existing configuration cp docker-compose.yml docker-compose-old.yml cp .env .env-old # 2. Reset and update repository git reset --hard git pull origin master git checkout master ``` -------------------------------- ### Enable Sudo for Script Execution (.env) Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/README.md Configuration setting in the .env.sample file to allow the 'fresh-start.sh' script to execute commands using sudo, necessary when dealing with file permissions. ```bash # Allow run commands with sudo if needed ALLOW_RUN_WITH_SUDO=true ``` -------------------------------- ### NGINX Proxy Automation fresh-start.sh Options Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt Command-line options for the fresh-start.sh script, allowing customization of container names, image versions, network settings, data paths, ports, and SSL policies. Essential for tailoring the deployment. ```bash # Container naming options -pn, --proxy-name=NAME # NGINX proxy container name (default: proxy-web-auto) -ln, --letsencrypt-name=NAME # Let's Encrypt container name (default: letsencrypt-auto) -gn, --docker-gen-name=NAME # Docker-gen container name (default: docker-gen-auto) # Image version options -piv, --proxy-image-version=VER # NGINX image version (default: latest) -liv, --letsencrypt-image-version=VER -giv, --docker-gen-image-version=VER # Network options -ip, --ip-address=IP # IPv4 address to bind (default: 0.0.0.0) -ipv6, --ipv6-address=IP # IPv6 address to bind --activate-ipv6 # Enable IPv6 support -net, --network-name=NAME # Docker network name (default: proxy) --ipv4-subnet=SUBNET # Custom IPv4 subnet --ipv6-subnet=SUBNET # Custom IPv6 subnet # Data and email -d, --data-files-location=PATH # Data storage path (default: ./data) -e, --default-email=EMAIL # Let's Encrypt notification email (required) # Port binding -phttp, --port-http=PORT # HTTP port (default: 80) -phttps, --port-https=PORT # HTTPS port (default: 443) # SSL policy -sp, --ssl-policy=POLICY # SSL policy (default: Mozilla-Intermediate) # Special options --docker-rootless # Enable Docker rootless mode --update-nginx-template # Update nginx.tmpl from upstream --use-nginx-conf-files # Copy custom nginx config files --skip-docker-image-check # Skip Docker Hub image verification --yes # Accept all defaults without prompts --debug # Enable debug output --silent # Suppress non-error output -h, --help # Show help message ``` -------------------------------- ### Connect Running Containers to New Docker Network Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/upgrade-guide.md This command is used to connect existing Docker containers to a newly created network, typically generated by the 'fresh-start.sh' script. It's essential if you are not using the same network name as before or if containers were not automatically added. Remember to replace '[YOUR_NEW_NETWORK_NAME]' and '[CONTAINER_NAME]' with your specific values. ```bash docker network connect [YOUR_NEW_NETWORK_NAME] [CONTAINER_NAME] ``` -------------------------------- ### Create Basic Authentication htpasswd File (Bash) Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/README.md This snippet demonstrates how to create a htpasswd file for basic authentication. It requires specifying the NGINX files path, the virtual host domain, and a username. The openssl command will prompt for the password. ```bash sudo sh -c "echo -n '[username]:' >> ${NGINX_FILES_PATH}/htpasswd/${VIRTUAL_HOST}" sudo sh -c "openssl passwd -apr1 >> ${NGINX_FILES_PATH}/htpasswd/${VIRTUAL_HOST}" ``` -------------------------------- ### Create and Connect Custom Docker Network (Bash) Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/README.md This bash script illustrates how to create a custom Docker network and connect existing containers (nginx-web, nginx-gen, nginx-letsencrypt) to it for better organization. ```bash docker network create myownnetwork docker network connect myownnetwork nginx-web docker network connect myownnetwork nginx-gen docker network connect myownnetwork nginx-letsencrypt ``` -------------------------------- ### Run Test Web Server Container (Docker) Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/README.md This Docker command runs an Alpine-based HTTP server container for testing purposes, mapping it to a specified virtual host and network. The container is named 'test-web'. ```bash docker run -dit -e VIRTUAL_HOST=your.domain.com --network=proxy --name test-web httpd:alpine ``` -------------------------------- ### Deploying Web Applications with Docker (SSL) Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt Shows how to deploy web applications with automatic SSL certificate provisioning using Let's Encrypt. It requires setting LETSENCRYPT_HOST and LETSENCRYPT_EMAIL environment variables. This is ideal for secure web access. ```bash # Full SSL deployment with Let's Encrypt docker run -d \ -e VIRTUAL_HOST=secure.example.com \ -e LETSENCRYPT_HOST=secure.example.com \ -e LETSENCRYPT_EMAIL=admin@example.com \ --network=proxy \ --name secure_app \ httpd:alpine # Multiple domains with SSL docker run -d \ -e VIRTUAL_HOST=example.com,www.example.com \ -e LETSENCRYPT_HOST=example.com,www.example.com \ -e LETSENCRYPT_EMAIL=admin@example.com \ --network=proxy \ --name multi_domain_app \ nginx:alpine ``` ```yaml # Docker Compose with SSL version: '3' services: wordpress: image: wordpress:latest environment: - VIRTUAL_HOST=blog.example.com - LETSENCRYPT_HOST=blog.example.com - LETSENCRYPT_EMAIL=admin@example.com - WORDPRESS_DB_HOST=db - WORDPRESS_DB_PASSWORD=secret networks: - proxy - backend depends_on: - db db: image: mysql:8.0 environment: - MYSQL_ROOT_PASSWORD=secret - MYSQL_DATABASE=wordpress networks: - backend volumes: - db_data:/var/lib/mysql networks: proxy: external: true backend: internal: true volumes: db_data: ``` -------------------------------- ### Copy Configuration Files for Backup Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/upgrade-guide.md This command copies the current 'docker-compose.yml' and '.env' files to backup files named 'docker-compose-old.yml' and '.env-old' respectively. This is a preliminary step before updating the Git repository to preserve the existing configuration. ```bash $ cp docker-compose.yml docker-compose-old.yml $ cp .env .env-old ``` -------------------------------- ### Configure Alternative Ports for HTTP/HTTPS (Shell) Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/HOWTO-Synology.md This snippet shows how to configure alternative local ports for HTTP and HTTPS in a .env file. This is useful to avoid conflicts with default web servers, such as those on Synology NAS. Ensure your router forwards external ports to these internal Docker host ports. ```shell # Set the local exposed ports for http and https - this will allow you to run with a legacy web # server already installed for local use # # NOTE: For this to function your internet router must forward the official ports to the mapped ports - # in this example external port 80 to docker host 81 and external port 443 to docker host 444 # DOCKER_HTTP=81 DOCKER_HTTPS=444 ``` -------------------------------- ### Configure Virtual Port with Docker Run (Bash) Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/README.md This command shows how to set the VIRTUAL_PORT environment variable when running a Docker container directly using the `docker run` command. ```bash docker run [...] -e VIRTUAL_PORT=8545 [...] ``` -------------------------------- ### Environment Variables Reference (.env file) Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt This is a reference for the environment variables used in the `.env` configuration file. It outlines settings for script behavior, container naming, network binding, data storage, logging, port configuration, SSL policies, Let's Encrypt settings, and Cloudflare integration. ```bash # .env configuration file # Script settings PID_FILE=.fresh_start.pid ALLOW_RUN_WITH_SUDO=false # Container naming NGINX_WEB_SEVICE_NAME=proxy-web NGINX_IMAGE_VERSION=stable-alpine DOCKER_GEN_SEVICE_NAME=docker-gen DOCKER_GEN_IMAGE_VERSION=latest LETS_ENCRYPT_SEVICE_NAME=acme-companion NGINX_PROXY_COMPANION_IMAGE_VERSION=latest # Network binding IPv4=0.0.0.0 IPv6=::0 NETWORK=proxy # Data storage NGINX_FILES_PATH=./data # Logging configuration NGINX_WEB_LOG_DRIVER=json-file NGINX_WEB_LOG_MAX_SIZE=4m NGINX_WEB_LOG_MAX_FILE=10 NGINX_GEN_LOG_DRIVER=json-file NGINX_GEN_LOG_MAX_SIZE=2m NGINX_GEN_LOG_MAX_FILE=10 NGINX_LETSENCRYPT_LOG_DRIVER=json-file NGINX_LETSENCRYPT_LOG_MAX_SIZE=2m NGINX_LETSENCRYPT_LOG_MAX_FILE=10 # Port configuration DOCKER_HTTP_=80 DOCKER_HTTPS=443 # SSL policy (Mozilla-Modern, Mozilla-Intermediate, Mozilla-Old, AWS-*) #SSL_POLICY=Mozilla-Modern # Let's Encrypt email DEFAULT_EMAIL=mail@yourdomain.tld # Default host for unmatched requests DEFAULT_HOST= # Docker rootless mode DOCKER_HOST_ROOTLESS_PATH= # Cloudflare DNS-01 integration CLOUDFLARE_DNS_TOKEN= ``` -------------------------------- ### Update Git Repository and Submodules Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/upgrade-guide.md This snippet covers resetting the local repository to the latest master branch, pulling changes, and initializing/updating submodules. It's crucial for ensuring the project is up-to-date before running upgrade scripts. ```bash $ git reset --hard $ git pull origin master $ git checkout master $ git submodule init $ git submodule update ``` -------------------------------- ### Stop and Remove Test Container Manually (Docker) Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/README.md Alternative method to stop and remove the 'test-web' container using direct Docker commands. ```bash docker stop test-web && docker rm test-web ``` -------------------------------- ### Stop and Remove Test Container (Bash) Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/README.md This script is used to stop and remove the test web server container created during the testing phase. ```bash ./stop.sh ``` -------------------------------- ### Deploying Web Applications with Docker (HTTP) Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt Demonstrates deploying web applications using Docker containers with HTTP-only access. It utilizes the VIRTUAL_HOST environment variable for automatic Nginx proxy configuration. This method is suitable for non-sensitive traffic. ```bash # Simple HTTP-only deployment docker run -d \ -e VIRTUAL_HOST=mysite.example.com \ --network=proxy \ --name my_app \ httpd:alpine # Custom port mapping (when container listens on non-standard port) docker run -d \ -e VIRTUAL_HOST=api.example.com \ -e VIRTUAL_PORT=8080 \ --network=proxy \ --name my_api \ node:alpine ``` ```yaml # Using docker-compose for HTTP service version: '3' services: webapp: image: nginx:alpine environment: - VIRTUAL_HOST=webapp.example.com networks: - proxy networks: proxy: external: true ``` -------------------------------- ### Connect Proxy to Multiple Docker Networks (Bash) Source: https://context7.com/evertramos/nginx-proxy-automation/llms.txt This section explains how to connect the Nginx proxy to additional Docker networks to manage traffic for containers in isolated network environments. It covers creating a new network, connecting proxy containers to it, deploying a service on the custom network, inspecting network details, and disconnecting containers. ```bash # Create a custom network docker network create myownnetwork # Connect proxy containers to the new network docker network connect myownnetwork nginx-proxy-automation-web docker network connect myownnetwork nginx-proxy-automation-gen docker network connect myownnetwork nginx-proxy-automation-letsencrypt # Deploy a service on the custom network docker run -d \ -e VIRTUAL_HOST=isolated.example.com \ -e LETSENCRYPT_HOST=isolated.example.com \ -e LETSENCRYPT_EMAIL=admin@example.com \ --network=myownnetwork \ --name isolated_app \ nginx:alpine # List connected networks docker network inspect myownnetwork # Disconnect from network docker network disconnect myownnetwork nginx-proxy-automation-web ``` -------------------------------- ### Reload Nginx Proxy Configuration (Bash) Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/README.md This bash command reloads the Nginx proxy configuration without downtime, which is useful after changes like setting up basic authentication. It assumes the proxy container is named `${NGINX_WEB}`. ```bash docker exec -it ${NGINX_WEB} nginx -s reload ``` -------------------------------- ### Remove Old Docker Compose and Environment Files Source: https://github.com/evertramos/nginx-proxy-automation/blob/main/docs/upgrade-guide.md This command removes the old Docker Compose configuration file and the old environment file. It is typically used after a successful update to clean up unused files and free up disk space. ```bash rm docker-compose-old.yml .env-old ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.