본문 바로가기

리눅스

[리눅스] envoy를 사용하는 도커 컨테이너 리버스 프록시(docker container reverse proxy)

반응형

envoy를 사용하는 도커 컨테이너 리버스 프록시(docker container reverse proxy)

docker-compose.yml 편집

vim docker-compose.yml
version: '3.9'
services:

  envoy:
    image: envoyproxy/envoy:v1.25-latest
    restart: unless-stopped
    container_name: envoy
    hostname: envoy
    volumes:
      - ./envoy_conf/envoy.yaml:/etc/envoy/envoy.yaml
    ports:
      - ${PORT_ADMIN:-9901}:9901
      - ${PORT_DEFAULT:-10000}:10000

도커 이미지 pull

docker-compose pull

envoy.yaml 파일 생성

docker run -d envoyproxy/envoy:v1.25-latest

envoy 컨테이너 ID 확인

docker ps --filter ancestor=envoyproxy/envoy:v1.25-latest --format={{.ID}}

envoy 컨테이너에 있는 envoy.yaml 파일을 로컬 디렉터리로 복사(docker cp)

docker cp 61a54936d0e3:/etc/envoy/envoy.yaml ./envoy_conf/envoy.yaml
$ cat envoy_conf/envoy.yaml
admin:
  address:
    socket_address:
      protocol: TCP
      address: 0.0.0.0
      port_value: 9901
static_resources:
  listeners:
  - name: listener_0
    address:
      socket_address:
        protocol: TCP
        address: 0.0.0.0
        port_value: 10000
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          scheme_header_transformation:
            scheme_to_overwrite: https
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["*"]
              routes:
              - match:
                  prefix: "/"
                route:
                  host_rewrite_literal: www.envoyproxy.io
                  cluster: service_envoyproxy_io
          http_filters:
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
  clusters:
  - name: service_envoyproxy_io
    connect_timeout: 30s
    type: LOGICAL_DNS
    # Comment out the following line to test on v6 networks
    dns_lookup_family: V4_ONLY
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: service_envoyproxy_io
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: www.envoyproxy.io
                port_value: 443
    transport_socket:
      name: envoy.transport_sockets.tls
      typed_config:
        "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
        sni: www.envoyproxy.io

도커 컨테이너 실행

docker-compose up -d

도커 컨테이너 목록 확인

docker-compose ps
$ docker-compose ps
NAME                IMAGE                           COMMAND                  SERVICE             CREATED             STATUS              PORTS
envoy               envoyproxy/envoy:v1.25-latest   "/docker-entrypoint.…"   envoy               4 minutes ago       Up 4 minutes        0.0.0.0:9901->9901/tcp, :::9901->9901/tcp, 0.0.0.0:10000->10000/tcp, :::10000->10000/tcp

웹 브라우저 http://192.168.0.51:9901

 

참고URL

- Getting Started : https://www.envoyproxy.io/docs/envoy/latest/start/docker

- Terminology : https://www.envoyproxy.io/docs/envoy/v1.25.0/intro/arch_overview/intro/terminology

- Using the Envoy Docker Image : https://www.envoyproxy.io/docs/envoy/latest/start/docker

- docker hub : https://hub.docker.com/r/envoyproxy/envoy

- Configuration: Static : https://www.envoyproxy.io/docs/envoy/latest/start/quick-start/configuration-static

 

728x90
반응형