Giter VIP home page Giter VIP logo

nginx-to-docker's Introduction

Nginx-to-Docker

Description

Nginx-to-Docker is a Docker image acting as a reverse proxy, enabling routing of incoming HTTP traffic to specific Docker containers based on domain names.

Features

  • Facilitates easy redirection of HTTP traffic to different containers based on domain names.
  • Configuration through environment variables for efficient routing.

Usage

Prerequisites

Pull the Docker Image

docker pull igormuba/nginx-to-docker:latest

Run the Nginx-to-Docker Container

docker run -d \
    --name nginx-to-docker \
    -e TEST1=test1.com_nginx-to-docker-container-1:3000 \
    -e TEST2=test2.com_nginx-to-docker-ontainer-1:3000 \
    -p 80:80 \
    igormuba/nginx-to-docker:latest

In the example above connections received on the nginx docker container from the domain test1.com will be redirected to the container nginx-to-docker-container-1:3000 and test2.com to nginx-to-docker-ontainer-1:3000

Docker Compose Usage

Utilize Docker Compose to manage your Nginx-to-Docker setup. Below is an example of a docker-compose.yml file:

version: "3"
services:
  container-1:
    image: user/image:latest
    container_name: nginx-to-docker-container-1
    ports:
      - "3000:3000"
    networks:
      - my_network
  container-2:
    image: user/image:latest
    container_name: nginx-to-docker-container-2
    ports:
      - "3000:3000"
    networks:
      - my_network
  nginx-to-docker:
    image: igormuba/nginx-to-docker:latest
    environment:
      - TEST1=test1.com_nginx-to-docker-container-1:3000
      - TEST2=test2.com_nginx-to-docker-container-2:3000
    ports:
      - "80:80"
networks:
  my_network:
    driver: bridge

Replace the image names, environment variables, and ports according to your specific configuration needs.

In the example above we are on the same docker-compose file setting the service containers and also setting the nginx-to-container to use nginx to redirect traffic from the domains to their respectinve dockers.

Understanding Environment Variables

  • Environment variables are used in pairs, with each pair representing a domain and its corresponding Docker container. These variables follow the pattern: `TESTX=DOMAIN_CONTAINER:PORT``, where:
    • TESTX refers to the placeholder for the domain and container pair, where X represents a unique identifier (e.g., TEST1, TEST2).
    • DOMAIN signifies the domain name that will be mapped to the specified container.
    • CONTAINER points to the Docker container and its port to which the traffic for the given domain will be directed.
    • Ensure each pair is separated by an underscore _.

Custom Configuration

To customize routing for your domains, update the environment variables with the required domain names and corresponding Docker containers following the specified format.

nginx-to-docker's People

Contributors

igormuba avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.