0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

envoyでhttps対応

Last updated at Posted at 2021-06-17

動機

ローカルで動かしているwebサービスをhttps化したい。
nginx, haproxy使うのはよく見かけるけど、せっかくなのでenvoyで同じことをしてみたい。

設定

v3書式対応。
ローカルの10001で立っているサービスを10000でhttps化する。

envoy.yaml
static_resources:
  listeners:
  - address:
      socket_address:
        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
          access_log:
            name: back
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
          codec_type: AUTO
          stat_prefix: back
          route_config:
            name: back
            virtual_hosts:
            - name: back
              domains:
              - "*"
              routes:
              - match:
                  prefix: "/"
                route:
                  cluster: back
          http_filters:
          - name: envoy.filters.http.router
      transport_socket:
        name: envoy.transport_sockets.tls
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
          common_tls_context:
            tls_certificates:
            - certificate_chain: {filename: "/etc/ssl/envoy/crt"}
              private_key: {filename: "/etc/ssl/envoy/key"}
  clusters:
  - name: back
    connect_timeout: 0.5s
    type: STATIC
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: back
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: 1270.0.01
                port_value: 10001

起動

dockerで。
事前に証明書と鍵をカレントのkey/{crt,key}に置いておく

$ docker run -v `pwd`/envoy.yaml:/etc/envoy/envoy.yaml -v `pwd`/key:/etc/ssl/envoy -p 10000:10000 -d --rm --name envoy envoyproxy/envoy:v1.18-latest
0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?