nginx-proxy

最後更新: 2019-01-17

介紹

 

 


nginx

 

Official build of Nginx

Homepage: https://hub.docker.com/r/_/nginx/

# Get image

docker pull docker.io/nginx:stable

# Get default configure file

docker run --name tmp-nginx -d nginx:stable

mkdir -p /data/nginx

docker cp tmp-nginx:/etc/nginx /data/nginx

mv /data/nginx/nginx /data/nginx/conf

docker stop tmp-nginx

docker rm tmp-nginx

# Start new nginx

mkdir /data/nginx/conf

mkdir /data/nginx/html

mkdir /data/nginx/logs

docker run \
  --name mynginx \
  -v "/data/nginx/conf":/etc/nginx \  
  -v "/data/nginx/logs":/var/log/nginx \  
  -v "/data/nginx/html":/usr/share/nginx/html \
  -e "TZ=Asia/Hong_Kong" \
  -p 80:80 \
  -d nginx:stable

# Config timezone

a) docker run -v /etc/timezone:/etc/timezone:ro

b) docker run -e "TZ=Asia/Kolkata"

 


nginx-proxy

 

HomePage: https://github.com/jwilder/nginx-proxy

Start

docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro \
--name MyProxy --net MyNetwork \
jwilder/nginx-proxy

Connect another network

docker network connect my-other-network my-nginx-proxy

Docker Compose

version: '2'

services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro

  whoami:
    image: jwilder/whoami
    environment:
      - VIRTUAL_HOST=datahunter.org,www.datahunter.org