Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: Add TLS sandbox #13844

Merged
merged 45 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5afbda6
examples: Add TLS sandbox
phlax Oct 31, 2020
92f36fe
docs/ci: Update docs publishing
phlax Oct 30, 2020
76c9d60
remove pipeline dep check
phlax Oct 31, 2020
34b9c06
docs/
phlax Oct 31, 2020
e7e21a9
docs/
phlax Oct 31, 2020
e39f44a
examples/
phlax Oct 31, 2020
535bc91
docs/
phlax Oct 31, 2020
d687992
docs/
phlax Oct 31, 2020
420fc4c
examples/
phlax Oct 31, 2020
3b7b0fa
docs/
phlax Oct 31, 2020
7734c12
docs/
phlax Oct 31, 2020
b95da5d
examples/
phlax Oct 31, 2020
e01647e
examples/
phlax Oct 31, 2020
815eaf1
docs/
phlax Oct 31, 2020
3593e4e
Revert "remove pipeline dep check"
phlax Oct 31, 2020
2e28810
Revert "docs/ci: Update docs publishing"
phlax Oct 31, 2020
5213817
Add responds_without utility function
phlax Nov 2, 2020
c149344
examples/
phlax Nov 2, 2020
c36490c
Merge branch 'master' into examples-tls-sandbox
phlax Nov 10, 2020
87d9b1e
docs/
phlax Nov 10, 2020
567a5d6
docs/
phlax Nov 10, 2020
db3b14f
docs/
phlax Nov 10, 2020
5f13d12
docs/
phlax Nov 10, 2020
4dfbb8e
Merge branch 'master' into examples-tls-sandbox
phlax Nov 10, 2020
db255b9
docs/
phlax Nov 10, 2020
002b836
docs/
phlax Nov 10, 2020
6a1d0a0
docs/
phlax Nov 10, 2020
34cca9c
docs/
phlax Nov 10, 2020
05af2f3
docs/
phlax Nov 11, 2020
04f0485
docs/
phlax Nov 11, 2020
f705da7
docs/
phlax Nov 11, 2020
72d3926
docs/
phlax Nov 11, 2020
8846c46
docs/
phlax Nov 11, 2020
e09cde3
docs/
phlax Nov 11, 2020
56ba320
docs/
phlax Nov 11, 2020
0077912
docs/
phlax Nov 11, 2020
4580de1
docs/
phlax Nov 11, 2020
b78290a
docs/
phlax Nov 11, 2020
12fcf2d
docs/
phlax Nov 11, 2020
97a6a1a
docs/
phlax Nov 11, 2020
aee256a
docs/
phlax Nov 11, 2020
f1b1aca
docs/
phlax Nov 11, 2020
2aa4bac
docs/
phlax Nov 11, 2020
2f6d39c
docs/
phlax Nov 11, 2020
496e049
docs/
phlax Nov 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .azure-pipelines/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ stages:
GCP_SERVICE_ACCOUNT_KEY: $(GcpServiceAccountKey)
displayName: "Generate docs"

- script: ci/run_envoy_docker.sh 'ci/upload_gcs_artifact.sh /source/generated/docs docs'
- script: |
SHORT_COMMIT_SHA=$(git log --pretty=%P -n 1 | cut -d' ' -f2 | head -c7)
phlax marked this conversation as resolved.
Show resolved Hide resolved
export SHORT_COMMIT_SHA
ci/run_envoy_docker.sh 'ci/upload_gcs_artifact.sh /source/generated/docs docs'
displayName: "Upload Docs to GCS"
env:
ENVOY_DOCKER_BUILD_DIR: $(Build.StagingDirectory)
Expand Down Expand Up @@ -167,7 +170,7 @@ stages:
AZP_BRANCH: $(Build.SourceBranch)

- stage: linux_x64
dependsOn: ["precheck"]
phlax marked this conversation as resolved.
Show resolved Hide resolved
dependsOn: []
# For post-submit builds, continue even if precheck fails
condition: and(not(canceled()), or(succeeded(), eq(variables['PostSubmit'], true)))
jobs:
Expand All @@ -181,7 +184,7 @@ stages:
ciTarget: bazel.release

- stage: linux_arm64
dependsOn: ["precheck"]
dependsOn: []
# For post-submit builds, continue even if precheck fails
condition: and(not(canceled()), or(succeeded(), eq(variables['PostSubmit'], true)))
jobs:
Expand Down
1 change: 1 addition & 0 deletions ci/run_envoy_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ docker run --rm \
-e BAZELISK_BASE_URL \
-e ENVOY_BUILD_ARCH \
-e SLACK_TOKEN \
-e SHORT_COMMIT_SHA \
-e BUILD_URI\
-e REPO_URI \
"${ENVOY_BUILD_IMAGE}" \
Expand Down
9 changes: 7 additions & 2 deletions ci/upload_gcs_artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ if [ ! -d "${SOURCE_DIRECTORY}" ]; then
exit 1
fi

BRANCH=${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER:-${BUILD_SOURCEBRANCHNAME}}
GCS_LOCATION="${GCS_ARTIFACT_BUCKET}/${BRANCH}/${TARGET_SUFFIX}"
if [ -n "${SHORT_COMMIT_SHA}" ]; then
UPLOAD_PATH="${SHORT_COMMIT_SHA}"
else
UPLOAD_PATH="${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER:-${BUILD_SOURCEBRANCHNAME}}"
fi

GCS_LOCATION="${GCS_ARTIFACT_BUCKET}/${UPLOAD_PATH}/${TARGET_SUFFIX}"

echo "Uploading to gs://${GCS_LOCATION} ..."
gsutil -mq rsync -dr "${SOURCE_DIRECTORY}" "gs://${GCS_LOCATION}"
Expand Down
1 change: 1 addition & 0 deletions docs/root/start/sandboxes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ features. The following sandboxes are available:
mysql
postgres
redis
tls
wasm-cc
zipkin_tracing
92 changes: 92 additions & 0 deletions docs/root/start/sandboxes/tls.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
.. _install_sandboxes_tls:

TLS
===

This example walks through some of the ways that Envoy can be configured to make
use of encrypted connections using ``TLS`` over ``HTTP``.
phlax marked this conversation as resolved.
Show resolved Hide resolved

It demonstrates a number of commonly used proxying and ``TLS`` termination patterns:

- ``https`` -> ``http``
- ``https`` -> ``https``
- ``http`` -> ``https``
- ``https`` passthrough

.. include:: _include/docker-env-setup.rst

Change directory to ``examples/tls`` in the Envoy repository.

Step 3: Build the sandbox
*************************

.. code-block:: console

$ pwd
envoy/examples/tls
$ docker-compose pull
$ docker-compose up --build -d
$ docker-compose ps

Name Command State Ports
-----------------------------------------------------------------------------------------------
tls_proxy-https-to-http_1 /docker-entrypoint.sh /usr ... Up 0.0.0.0:10000->10000/tcp
tls_proxy-https-to-https_1 /docker-entrypoint.sh /usr ... Up 0.0.0.0:10001->10000/tcp
tls_proxy-http-to-https_1 /docker-entrypoint.sh /usr ... Up 0.0.0.0:10002->10000/tcp
tls_proxy-https-passthrough_1 /docker-entrypoint.sh /usr ... Up 0.0.0.0:10003->10000/tcp
tls_service-http_1 node ./index.js Up
tls_service-https_1 node ./index.js Up

Step 4: Test proxying ``https`` -> ``http``
********************************************

The Envoy proxy listening on https://localhost:10000 terminates ``HTTPS`` and proxies to the upstream ``HTTP`` service.

phlax marked this conversation as resolved.
Show resolved Hide resolved
.. code-block:: console

$ curl -sk https://localhost:10000 | jq '.headers["x-forwarded-proto"]'
"https"

$ curl -sk https://localhost:10000 | jq '.os.hostname'
"service-http"

Step 5: Test proxying ``https`` -> ``https``
********************************************

The Envoy proxy listening on https://localhost:10001 terminates ``HTTPS`` and proxies to the upstream ``HTTPS`` service.

.. code-block:: console

$ curl -sk https://localhost:10001 | jq '.headers["x-forwarded-proto"]'
"https"

$ curl -sk https://localhost:10001 | jq '.os.hostname'
"service-https"

Step 6: Test proxying ``http`` -> ``https``
*******************************************

The Envoy proxy listening on https://localhost:10002 terminates ``HTTP`` and proxies to the upstream ``HTTPS`` service.
phlax marked this conversation as resolved.
Show resolved Hide resolved

.. code-block:: console

$ curl -s http://localhost:10002 | jq '.headers["x-forwarded-proto"]'
"http"

$ curl -s http://localhost:10002 | jq '.os.hostname'
"service-https"


Step 7: Test proxying ``https`` passthrough
*******************************************

The Envoy proxy listening on https://localhost:10003 proxies directly to the upstream ``HTTPS`` service which
does the termination.
phlax marked this conversation as resolved.
Show resolved Hide resolved

.. code-block:: console

$ curl -s http://localhost:10002 | jq '.headers["x-forwarded-proto"]'
phlax marked this conversation as resolved.
Show resolved Hide resolved
"http"

$ curl -s http://localhost:10002 | jq '.os.hostname'
"service-https"
5 changes: 5 additions & 0 deletions examples/tls/Dockerfile-proxy-http-https
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM envoyproxy/envoy-dev:latest

COPY ./envoy-http-https.yaml /etc/envoy.yaml
RUN chmod go+r /etc/envoy.yaml
CMD ["/usr/local/bin/envoy", "-c /etc/envoy.yaml"]
5 changes: 5 additions & 0 deletions examples/tls/Dockerfile-proxy-https-http
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM envoyproxy/envoy-dev:latest

COPY ./envoy-https-http.yaml /etc/envoy.yaml
RUN chmod go+r /etc/envoy.yaml
CMD ["/usr/local/bin/envoy", "-c /etc/envoy.yaml"]
5 changes: 5 additions & 0 deletions examples/tls/Dockerfile-proxy-https-https
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM envoyproxy/envoy-dev:latest

COPY ./envoy-https-https.yaml /etc/envoy.yaml
RUN chmod go+r /etc/envoy.yaml
CMD ["/usr/local/bin/envoy", "-c /etc/envoy.yaml"]
5 changes: 5 additions & 0 deletions examples/tls/Dockerfile-proxy-https-passthrough
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM envoyproxy/envoy-dev:latest

COPY ./envoy-https-passthrough.yaml /etc/envoy.yaml
RUN chmod go+r /etc/envoy.yaml
CMD ["/usr/local/bin/envoy", "-c /etc/envoy.yaml"]
2 changes: 2 additions & 0 deletions examples/tls/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
To learn about this sandbox and for instructions on how to run it please head over
to the [Envoy docs](https://www.envoyproxy.io/docs/envoy/latest/start/sandboxes/double-proxy.html).
phlax marked this conversation as resolved.
Show resolved Hide resolved
42 changes: 42 additions & 0 deletions examples/tls/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "3.7"
services:

proxy-https-to-http:
build:
context: .
dockerfile: Dockerfile-proxy-https-http
ports:
- "10000:10000"

proxy-https-to-https:
build:
context: .
dockerfile: Dockerfile-proxy-https-https
ports:
- "10001:10000"

proxy-http-to-https:
build:
context: .
dockerfile: Dockerfile-proxy-http-https
ports:
- "10002:10000"

proxy-https-passthrough:
build:
context: .
dockerfile: Dockerfile-proxy-https-passthrough
ports:
- "10003:10000"

service-http:
image: mendhak/http-https-echo
hostname: service-http
environment:
- HTTPS_PORT=0

service-https:
image: mendhak/http-https-echo
hostname: service-https
environment:
- HTTP_PORT=0
45 changes: 45 additions & 0 deletions examples/tls/envoy-http-https.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: app
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: service-https
http_filters:
- name: envoy.filters.http.router

clusters:
- name: service-https
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: service-https
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: service-https
port_value: 443
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
phlax marked this conversation as resolved.
Show resolved Hide resolved
104 changes: 104 additions & 0 deletions examples/tls/envoy-https-http.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: app
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: service-http
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:
# The following self-signed certificate pair is generated using:
# $ openssl req -x509 -newkey rsa:2048 -keyout a/front-proxy-key.pem -out a/front-proxy-crt.pem -days 3650 -nodes -subj '/CN=front-envoy'
#
# Instead of feeding it as an inline_string, certificate pair can also be fed to Envoy
# via filename. Reference: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/base.proto#config-core-v3-datasource.
#
# Or in a dynamic configuration scenario, certificate pair can be fetched remotely via
# Secret Discovery Service (SDS). Reference: https://www.envoyproxy.io/docs/envoy/latest/configuration/security/secret.
certificate_chain:
inline_string: |
-----BEGIN CERTIFICATE-----
MIICqDCCAZACCQCquzpHNpqBcDANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDDAtm
cm9udC1lbnZveTAeFw0yMDA3MDgwMTMxNDZaFw0zMDA3MDYwMTMxNDZaMBYxFDAS
BgNVBAMMC2Zyb250LWVudm95MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
AQEAthnYkqVQBX+Wg7aQWyCCb87hBce1hAFhbRM8Y9dQTqxoMXZiA2n8G089hUou
oQpEdJgitXVS6YMFPFUUWfwcqxYAynLK4X5im26Yfa1eO8La8sZUS+4Bjao1gF5/
VJxSEo2yZ7fFBo8M4E44ZehIIocipCRS+YZehFs6dmHoq/MGvh2eAHIa+O9xssPt
ofFcQMR8rwBHVbKy484O10tNCouX4yUkyQXqCRy6HRu7kSjOjNKSGtjfG+h5M8bh
10W7ZrsJ1hWhzBulSaMZaUY3vh5ngpws1JATQVSK1Jm/dmMRciwlTK7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: 0.25s
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: service-http
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: service-http
port_value: 80
Loading