Enviroment

  • OS: CentOS Linux release 8.3.2011

部署

#分別建好 subconverter 和 nginx/conf.d 兩個文件夾
$ cd /root/nginx/conf.d
$ vim server.conf
$ cd /root/subconverter
$ vim docker-compose.yml
$ docker-compose -d

Docker-compose

!/root/subconverter/docker-compose.yml

version: "3"

services:
  subc:
    hostname: subc
    restart: always
    container_name: subc
    image: tindy2013/subconverter:latest
  subweb:
    hostname: subweb
    restart: always
    container_name: subweb
    image: careywong/subweb:latest
  nginx:
    hostname: nginx
    restart: always
    container_name: nginx
    image: nginx:latest
    ports:
      - "80:80"
      - "443:443"
    links:
      - "subc:subc"
      - "subweb:subweb"
    volumes:
      - /root/nginx/conf.d:/etc/nginx/conf.d

Nginx Conf

!/root/nginx/conf.d/server.conf
	
# vhost of subc with proxy
	
server {
        listen 80;
        server_name <domain>;
        location / {
                proxy_pass http://subc:25500;
        }
}

server {
        listen 80;
        server_name <domain>;
        location / {
                proxy_pass http://subweb;
        }        
}