[Portainer] Nginx Proxy Manager

  1. NPM 이란?
  2. NPM 설치
  3. NPM 사용법
  4. 문제점

1. NPM 이란?

Nginx Proxy Manager는 리버스 프록시, 리다이렉션, 보안 인증, SSL 인증서 관리를 GUI로 할 수 있게 도와주는 툴입니다.

Nginx Proxy Manager
Docker container and built in Web Application for managing Nginx proxy hosts with a simple, powerful interface, providing free SSL support via Let’s Encrypt

2. NPM 설치

빠른 설치 ( Quick Setup )

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt

상세 설치 ( Full Setup )

version: "3"
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP

    # Uncomment the next line if you uncomment anything in the section
    # environment:
      # Uncomment this if you want to change the location of 
      # the SQLite DB file within the container
      # DB_SQLITE_FILE: "/data/database.sqlite"

      # Uncomment this if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'

    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt

데이터 베이스 사용

  • 버전 확인 주의 MySQL v5.7.8+, MariaDB v10.2.7+
  • DB_MYSQL_* 환경 변수 사용시 SQLite 사용 못함
version: "3"
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP
    environment:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
      # Uncomment this if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - db

  db:
    image: 'jc21/mariadb-aria:latest'
    # Here are the minimum supported versions
    # MySQL v5.7.8+
    # MariaDB v10.2.7+
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
    volumes:
      - ./data/mysql:/var/lib/mysql

ARM devices

!! 주의사항 - jc21/mariadb-aria:latest 이미지가 특정 ARM devices 에서는 설치가 안됩니다. 이런경우 yobasystems/alpine-mariadb:latest 이지를 설치 또는 별도의 지원가능한 DBMS를 설치하면 됩니다.

3. NPM 사용법

최초 설정

프록시 매니저가 설치가 되면 81포트로 접속해줍니다(localhost:81)

최초 기본 설정 계정 정보로 로그인 하면 됩니다.

email: [email protected]
password: changeme

SSL 발급

상단의 SSL Certificates 메뉴에서 Add SSL Certificate를 선택하고 아래와 같이 채워넣으면 된다.

*.example.ccom 같은 와일드카드 도메인으로 인증 받기 위해서는 dns-challenge를 사용해야 한다. 이때 Cloudflare를 사용할 경우 토큰 생성 메뉴에서 DNS 토큰을 미리 만들어 줘야 한다.

아래처럼 와일드카드가 포함된 인증서를 발급이 완료된다.

[Hosts] - [Proxy Hosts] 로 이동해서 등록하고 사용하면 된다.

Schema 부분의 http 와 https 는 외부 연결과는 상관이 없다. NPM과 내부 서버 연결 방식을 설정 하는거라 내부 서버가 http 라도 외부 유저는 https로 보고 접속 가능한다.

위와 같이 설정 후 사용 가능하다.

Proxy 설정이 바뀌면 클라이언트의 인터넷 사용기록 삭제 에서 쿠키를 지워줘야 된다.

4. 문제점

Cloudflare 에서 SSL 설정을 Edge로 하면 잘 동작한다. (이경우 따로 내부에 인증서가 필요없음 클플에서 다 처리됨) Full 이상으로 설정시 에러가 발생하며 동작을 정상적으로 하지 않는다. 왜그런지 다시 확인해봐야됨

Edge로 사용시 forceSSL 설정하면 에러나느것 같음, 이부분들 관계에 대하여 추가 내용 확인이 필요함