diff --git a/Makefile b/Makefile index c9c265549..d24d61089 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,6 @@ DEVEL_DOCKER_COMPOSE_VOLMOUNT_MAC_FILE ?= docker-compose-devel-volmount-mac.yml DEVEL_DOCKER_COMPOSE_VOLMOUNT_DEFAULT_FILE ?= docker-compose-devel-volmount-default.yml PROVE_DOCKER_COMPOSE_FILE ?= docker-compose.prove.yml -FORWARD_PROXY_DOCKER_COMPOSE_FILE ?= docker-compose.forward-proxy.yml -UPSTREAM_TLS_DOCKER_COMPOSE_FILE ?= docker-compose.upstream-tls.yml DOCKER_VOLUME_NAME ?= apicast-local-volume @@ -167,20 +165,9 @@ gateway-logs: export IMAGE_NAME = does-not-matter gateway-logs: $(DOCKER) compose logs gateway -opentelemetry-gateway: ## run gateway instrumented with opentelemetry - $(DOCKER) compose run opentelemetry-instrumented-gateway - opentracing-gateway: ## run gateway instrumented with opentracing $(DOCKER) compose run opentracing-instrumented-gateway -# Environment described in ./examples/forward-proxy -forward-proxy-gateway: ## run gateway configured to run along with a forward proxy - $(DOCKER) compose -f $(FORWARD_PROXY_DOCKER_COMPOSE_FILE) run gateway - -# Environment described in ./examples/tlsv1.3-upstream -upstream-tls-gateway: ## run gateway configured to access upstream powered with TLS - $(DOCKER) compose -f $(UPSTREAM_TLS_DOCKER_COMPOSE_FILE) run gateway - test-runtime-image: export IMAGE_NAME ?= $(RUNTIME_IMAGE) test-runtime-image: clean-containers ## Smoke test the runtime image. Pass any docker image in IMAGE_NAME parameter. $(DOCKER) compose --version @@ -247,8 +234,6 @@ clean-containers: $(DOCKER) compose down --volumes --remove-orphans $(DOCKER) compose -f $(PROVE_DOCKER_COMPOSE_FILE) down --volumes --remove-orphans $(DOCKER) compose -f $(DEVEL_DOCKER_COMPOSE_FILE) -f $(DEVEL_DOCKER_COMPOSE_VOLMOUNT_FILE) down --volumes --remove-orphans - $(DOCKER) compose -f $(FORWARD_PROXY_DOCKER_COMPOSE_FILE) down --volumes --remove-orphans - $(DOCKER) compose -f $(UPSTREAM_TLS_DOCKER_COMPOSE_FILE) down --volumes --remove-orphans clean-deps: ## Remove all local dependency folders - rm -rf $(PROJECT_PATH)/lua_modules $(PROJECT_PATH)/local $(PROJECT_PATH)/.cpanm $(PROJECT_PATH)/vendor/cache $(PROJECT_PATH)/.cache : diff --git a/dev-environments/http-proxy-plain-http-upstream/Makefile b/dev-environments/http-proxy-plain-http-upstream/Makefile new file mode 100644 index 000000000..ccd279341 --- /dev/null +++ b/dev-environments/http-proxy-plain-http-upstream/Makefile @@ -0,0 +1,13 @@ +SHELL = /usr/bin/env bash -o pipefail +.SHELLFLAGS = -ec +.DEFAULT_GOAL := gateway +MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +WORKDIR := $(patsubst %/,%,$(dir $(MKFILE_PATH))) +DOCKER ?= $(shell which docker 2> /dev/null || echo "docker") + +gateway: ## run gateway configured to access upstream powered with TLS + $(DOCKER) compose -f docker-compose.yml run --service-ports gateway + +clean: + $(DOCKER) compose down --volumes --remove-orphans + $(DOCKER) compose -f docker-compose.yml down --volumes --remove-orphans diff --git a/dev-environments/http-proxy-plain-http-upstream/README.md b/dev-environments/http-proxy-plain-http-upstream/README.md new file mode 100644 index 000000000..a2c2dacd6 --- /dev/null +++ b/dev-environments/http-proxy-plain-http-upstream/README.md @@ -0,0 +1,51 @@ +# PROXY with upstream using plain HTTP 1.1 + +APIcast --> tiny proxy (connect to 443 but no cert installed) --> upstream (plain HTTP 1.1) + +APIcast configured with plain HTTP 1.1 upstream through a proxy. + +## Run the gateway + +Running local `apicast-test` docker image + +```sh +make gateway +``` + +Running custom apicast image + +```sh +make gateway IMAGE_NAME=quay.io/3scale/apicast:latest +``` + +Traffic between the proxy and upstream can be inspected looking at logs from `example.com` service + +``` +docker compose -p http-proxy-plain-http-upstream logs -f example.com +``` + +Proxy can be inspected looking at logs from `proxy` service + +``` +docker compose -p http-proxy-plain-http-upstream logs -f proxy +``` + +## Testing + +`GET` request + +```sh +curl --resolve get.example.com:8080:127.0.0.1 -v "http://get.example.com:8080/?user_key=123" +``` + +`POST` request + +```sh +curl --resolve post.example.com:8080:127.0.0.1 -v -X POST "http://post.example.com:8080/?user_key=123" +``` + +## Clean env + +```sh +make clean +``` diff --git a/dev-environments/http-proxy-plain-http-upstream/apicast-config.json b/dev-environments/http-proxy-plain-http-upstream/apicast-config.json new file mode 100644 index 000000000..668dbf625 --- /dev/null +++ b/dev-environments/http-proxy-plain-http-upstream/apicast-config.json @@ -0,0 +1,70 @@ +{ + "services": [ + { + "id": "1", + "backend_version": "1", + "proxy": { + "hosts": ["get.example.com"], + "api_backend": "http://example.com/get", + "backend": { + "endpoint": "http://127.0.0.1:8081", + "host": "backend" + }, + "policy_chain": [ + { + "name": "apicast.policy.http_proxy", + "configuration": { + "http_proxy": "http://proxy:443/" + } + }, + { + "name": "apicast.policy.apicast" + } + ], + "proxy_rules": [ + { + "http_method": "GET", + "pattern": "/", + "metric_system_name": "hits", + "delta": 1, + "parameters": [], + "querystring_parameters": {} + } + ] + } + }, + { + "id": "2", + "backend_version": "1", + "proxy": { + "hosts": ["post.example.com"], + "api_backend": "http://example.com/post", + "backend": { + "endpoint": "http://127.0.0.1:8081", + "host": "backend" + }, + "policy_chain": [ + { + "name": "apicast.policy.http_proxy", + "configuration": { + "http_proxy": "http://proxy:443/" + } + }, + { + "name": "apicast.policy.apicast" + } + ], + "proxy_rules": [ + { + "http_method": "POST", + "pattern": "/", + "metric_system_name": "hits", + "delta": 1, + "parameters": [], + "querystring_parameters": {} + } + ] + } + } + ] +} diff --git a/docker-compose.forward-proxy.yml b/dev-environments/http-proxy-plain-http-upstream/docker-compose.yml similarity index 52% rename from docker-compose.forward-proxy.yml rename to dev-environments/http-proxy-plain-http-upstream/docker-compose.yml index 6b214dc8c..97ed3c9b9 100644 --- a/docker-compose.forward-proxy.yml +++ b/dev-environments/http-proxy-plain-http-upstream/docker-compose.yml @@ -5,7 +5,8 @@ services: image: ${IMAGE_NAME:-apicast-test} depends_on: - proxy - - upstream + - example.com + - two.upstream environment: THREESCALE_CONFIG_FILE: /tmp/config.json THREESCALE_DEPLOYMENT_ENV: staging @@ -20,20 +21,23 @@ services: - "8080:8080" - "8090:8090" volumes: - - ./examples/forward-proxy/apicast-config.json:/tmp/config.json - upstream: - image: nginx:1.23.4 - expose: - - "443" - volumes: - - ./examples/forward-proxy/proxy-nginx.conf:/etc/nginx/nginx.conf - - ./examples/forward-proxy/upstream-cert/upstream.key:/etc/pki/tls.key - - ./examples/forward-proxy/upstream-cert/upstream.crt:/etc/pki/tls.crt + - ./apicast-config.json:/tmp/config.json proxy: build: - dockerfile: ./examples/forward-proxy/tinyproxy.Dockerfile + dockerfile: ./tinyproxy.Dockerfile expose: - "3128:3128" - "443:443" volumes: - - ./examples/forward-proxy/tinyproxy.conf:/etc/tinyproxy/tinyproxy.conf + - ./tinyproxy.conf:/etc/tinyproxy/tinyproxy.conf + example.com: + image: alpine/socat:1.7.4.4 + container_name: example.com + command: "-d -v -d TCP-LISTEN:80,reuseaddr,fork TCP:two.upstream:80" + expose: + - "443" + restart: unless-stopped + two.upstream: + image: kennethreitz/httpbin + expose: + - "80" diff --git a/examples/forward-proxy/tinyproxy.Dockerfile b/dev-environments/http-proxy-plain-http-upstream/tinyproxy.Dockerfile similarity index 100% rename from examples/forward-proxy/tinyproxy.Dockerfile rename to dev-environments/http-proxy-plain-http-upstream/tinyproxy.Dockerfile diff --git a/examples/forward-proxy/tinyproxy.conf b/dev-environments/http-proxy-plain-http-upstream/tinyproxy.conf similarity index 100% rename from examples/forward-proxy/tinyproxy.conf rename to dev-environments/http-proxy-plain-http-upstream/tinyproxy.conf diff --git a/dev-environments/https-proxy-upstream-tlsv1.3/Makefile b/dev-environments/https-proxy-upstream-tlsv1.3/Makefile new file mode 100644 index 000000000..fe6780662 --- /dev/null +++ b/dev-environments/https-proxy-upstream-tlsv1.3/Makefile @@ -0,0 +1,18 @@ +SHELL = /usr/bin/env bash -o pipefail +.SHELLFLAGS = -ec +.DEFAULT_GOAL := gateway +MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +WORKDIR := $(patsubst %/,%,$(dir $(MKFILE_PATH))) +DOCKER ?= $(shell which docker 2> /dev/null || echo "docker") + +gateway: ## run gateway configured to access upstream powered with TLS + $(DOCKER) compose -f docker-compose.yml run --service-ports gateway + +clean: + $(DOCKER) compose down --volumes --remove-orphans + $(DOCKER) compose -f docker-compose.yml down --volumes --remove-orphans + +certs: + $(MAKE) clean -C $(WORKDIR)/cert -f $(WORKDIR)/cert/Makefile + $(MAKE) ca -C $(WORKDIR)/cert -f $(WORKDIR)/cert/Makefile + $(MAKE) clientcerts -C $(WORKDIR)/cert -f $(WORKDIR)/cert/Makefile DOMAIN=example.com diff --git a/dev-environments/https-proxy-upstream-tlsv1.3/README.md b/dev-environments/https-proxy-upstream-tlsv1.3/README.md new file mode 100644 index 000000000..55a835a88 --- /dev/null +++ b/dev-environments/https-proxy-upstream-tlsv1.3/README.md @@ -0,0 +1,59 @@ +# PROXY with upstream using TLSv1.3 + +APIcast --> tiny proxy (connect to 443 but no cert installed) --> upstream (TLSv1.3) + +APIcast configured with TLSv1.3 powered upstream through a proxy. TLS termination endpoint is `socat`. + +APicast starts SSL tunnel (via HTTP CONNECT method) against proxy to access upstream configured with TLSv1.3 + +## Create the SSL Certificates + +```sh +make certs +``` + +## Run the gateway + +Running local `apicast-test` docker image + +```sh +make gateway +``` + +Running custom apicast image + +```sh +make gateway IMAGE_NAME=quay.io/3scale/apicast:latest +``` + +Traffic between the proxy and upstream can be inspected looking at logs from `example.com` service + +``` +docker compose -p https-proxy-upstream-tlsv13 logs -f example.com +``` + +Proxy can be inspected looking at logs from `proxy` service + +``` +docker compose -p https-proxy-upstream-tlsv13 logs -f proxy +``` + +## Testing + +`GET` request + +```sh +curl --resolve get.example.com:8080:127.0.0.1 -v "http://get.example.com:8080/?user_key=123" +``` + +`POST` request + +```sh +curl --resolve post.example.com:8080:127.0.0.1 -v -X POST "http://post.example.com:8080/?user_key=123" +``` + +## Clean env + +```sh +make clean +``` diff --git a/dev-environments/https-proxy-upstream-tlsv1.3/apicast-config.json b/dev-environments/https-proxy-upstream-tlsv1.3/apicast-config.json new file mode 100644 index 000000000..5227c5aaf --- /dev/null +++ b/dev-environments/https-proxy-upstream-tlsv1.3/apicast-config.json @@ -0,0 +1,70 @@ +{ + "services": [ + { + "id": "1", + "backend_version": "1", + "proxy": { + "hosts": ["get.example.com"], + "api_backend": "https://example.com/get", + "backend": { + "endpoint": "http://127.0.0.1:8081", + "host": "backend" + }, + "policy_chain": [ + { + "name": "apicast.policy.http_proxy", + "configuration": { + "https_proxy": "http://proxy:443/" + } + }, + { + "name": "apicast.policy.apicast" + } + ], + "proxy_rules": [ + { + "http_method": "GET", + "pattern": "/", + "metric_system_name": "hits", + "delta": 1, + "parameters": [], + "querystring_parameters": {} + } + ] + } + }, + { + "id": "2", + "backend_version": "1", + "proxy": { + "hosts": ["post.example.com"], + "api_backend": "https://example.com/post", + "backend": { + "endpoint": "http://127.0.0.1:8081", + "host": "backend" + }, + "policy_chain": [ + { + "name": "apicast.policy.http_proxy", + "configuration": { + "https_proxy": "http://proxy:443/" + } + }, + { + "name": "apicast.policy.apicast" + } + ], + "proxy_rules": [ + { + "http_method": "POST", + "pattern": "/", + "metric_system_name": "hits", + "delta": 1, + "parameters": [], + "querystring_parameters": {} + } + ] + } + } + ] +} diff --git a/dev-environments/https-proxy-upstream-tlsv1.3/cert/Makefile b/dev-environments/https-proxy-upstream-tlsv1.3/cert/Makefile new file mode 100644 index 000000000..e9efe9b61 --- /dev/null +++ b/dev-environments/https-proxy-upstream-tlsv1.3/cert/Makefile @@ -0,0 +1,16 @@ +clean: + - rm *.crt *.key *.pem *.csr + +ca: + openssl genrsa -out rootCA.key 2048 + openssl req -batch -new -x509 -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem + +clientcerts: + openssl req -subj '/CN=$(DOMAIN)' -newkey rsa:4096 -nodes \ + -sha256 \ + -days 3650 \ + -keyout $(DOMAIN).key \ + -out $(DOMAIN).csr + chmod +r $(DOMAIN).key + openssl x509 -req -in $(DOMAIN).csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out $(DOMAIN).crt -days 500 -sha256 + cat $(DOMAIN).key $(DOMAIN).crt >$(DOMAIN).pem diff --git a/dev-environments/https-proxy-upstream-tlsv1.3/docker-compose.yml b/dev-environments/https-proxy-upstream-tlsv1.3/docker-compose.yml new file mode 100644 index 000000000..9fa735f7c --- /dev/null +++ b/dev-environments/https-proxy-upstream-tlsv1.3/docker-compose.yml @@ -0,0 +1,45 @@ +--- +version: '3.8' +services: + gateway: + image: ${IMAGE_NAME:-apicast-test} + depends_on: + - proxy + - example.com + - two.upstream + environment: + THREESCALE_CONFIG_FILE: /tmp/config.json + THREESCALE_DEPLOYMENT_ENV: staging + APICAST_CONFIGURATION_LOADER: lazy + APICAST_WORKERS: 1 + APICAST_LOG_LEVEL: debug + APICAST_CONFIGURATION_CACHE: "0" + expose: + - "8080" + - "8090" + ports: + - "8080:8080" + - "8090:8090" + volumes: + - ./apicast-config.json:/tmp/config.json + proxy: + build: + dockerfile: ./tinyproxy.Dockerfile + expose: + - "3128:3128" + - "443:443" + volumes: + - ./tinyproxy.conf:/etc/tinyproxy/tinyproxy.conf + example.com: + image: alpine/socat:1.7.4.4 + container_name: example.com + command: "-v openssl-listen:443,reuseaddr,fork,cert=/etc/pki/example.com.pem,verify=0,openssl-min-proto-version=TLS1.3,openssl-max-proto-version=TLS1.3 TCP:two.upstream:80" + expose: + - "443" + restart: unless-stopped + volumes: + - ./cert/example.com.pem:/etc/pki/example.com.pem + two.upstream: + image: kennethreitz/httpbin + expose: + - "80" diff --git a/dev-environments/https-proxy-upstream-tlsv1.3/tinyproxy.Dockerfile b/dev-environments/https-proxy-upstream-tlsv1.3/tinyproxy.Dockerfile new file mode 100644 index 000000000..b8d4e49aa --- /dev/null +++ b/dev-environments/https-proxy-upstream-tlsv1.3/tinyproxy.Dockerfile @@ -0,0 +1,12 @@ +FROM alpine:3.17.3 + +LABEL summary="Forward proxy based on tinyproxy for development purposes" \ + description="Forward proxy based on tinyproxy for development purposes" \ + io.k8s.description="Forward proxy based on tinyproxy for development purposes" \ + io.k8s.display-name="Forward Proxy (Tinyproxy)" \ + io.openshift.tags="tinyproxy, proxy" \ + maintainer="3scale-engineering@redhat.com" + +RUN apk --no-cache add tinyproxy=1.11.1-r2 +ENTRYPOINT ["/usr/bin/tinyproxy"] +CMD ["-d"] diff --git a/dev-environments/https-proxy-upstream-tlsv1.3/tinyproxy.conf b/dev-environments/https-proxy-upstream-tlsv1.3/tinyproxy.conf new file mode 100644 index 000000000..ce08caa11 --- /dev/null +++ b/dev-environments/https-proxy-upstream-tlsv1.3/tinyproxy.conf @@ -0,0 +1,327 @@ +## +## tinyproxy.conf -- tinyproxy daemon configuration file +## +## This example tinyproxy.conf file contains example settings +## with explanations in comments. For decriptions of all +## parameters, see the tinproxy.conf(5) manual page. +## + +# +# User/Group: This allows you to set the user and group that will be +# used for tinyproxy after the initial binding to the port has been done +# as the root user. Either the user or group name or the UID or GID +# number may be used. +# +User tinyproxy +Group tinyproxy + +# +# Port: Specify the port which tinyproxy will listen on. Please note +# that should you choose to run on a port lower than 1024 you will need +# to start tinyproxy using root. +# +Port 443 + +# +# Listen: If you have multiple interfaces this allows you to bind to +# only one. If this is commented out, tinyproxy will bind to all +# interfaces present. +# +#Listen 192.168.0.1 + +# +# Bind: This allows you to specify which interface will be used for +# outgoing connections. This is useful for multi-home'd machines where +# you want all traffic to appear outgoing from one particular interface. +# +#Bind 192.168.0.1 + +# +# BindSame: If enabled, tinyproxy will bind the outgoing connection to the +# ip address of the incoming connection. +# +#BindSame yes + +# +# Timeout: The maximum number of seconds of inactivity a connection is +# allowed to have before it is closed by tinyproxy. +# +Timeout 600 + +# +# ErrorFile: Defines the HTML file to send when a given HTTP error +# occurs. You will probably need to customize the location to your +# particular install. The usual locations to check are: +# /usr/local/share/tinyproxy +# /usr/share/tinyproxy +# /etc/tinyproxy +# +#ErrorFile 404 "/usr/share/tinyproxy/404.html" +#ErrorFile 400 "/usr/share/tinyproxy/400.html" +#ErrorFile 503 "/usr/share/tinyproxy/503.html" +#ErrorFile 403 "/usr/share/tinyproxy/403.html" +#ErrorFile 408 "/usr/share/tinyproxy/408.html" + +# +# DefaultErrorFile: The HTML file that gets sent if there is no +# HTML file defined with an ErrorFile keyword for the HTTP error +# that has occured. +# +DefaultErrorFile "/usr/share/tinyproxy/default.html" + +# +# StatHost: This configures the host name or IP address that is treated +# as the stat host: Whenever a request for this host is received, +# Tinyproxy will return an internal statistics page instead of +# forwarding the request to that host. The default value of StatHost is +# tinyproxy.stats. +# +#StatHost "tinyproxy.stats" +# + +# +# StatFile: The HTML file that gets sent when a request is made +# for the stathost. If this file doesn't exist a basic page is +# hardcoded in tinyproxy. +# +StatFile "/usr/share/tinyproxy/stats.html" + +# +# LogFile: Allows you to specify the location where information should +# be logged to. If you would prefer to log to syslog, then disable this +# and enable the Syslog directive. These directives are mutually +# exclusive. +# +#LogFile "/var/log/tinyproxy/tinyproxy.log" + +# +# Syslog: Tell tinyproxy to use syslog instead of a logfile. This +# option must not be enabled if the Logfile directive is being used. +# These two directives are mutually exclusive. +# +#Syslog On + +# +# LogLevel: +# +# Set the logging level. Allowed settings are: +# Critical (least verbose) +# Error +# Warning +# Notice +# Connect (to log connections without Info's noise) +# Info (most verbose) +# +# The LogLevel logs from the set level and above. For example, if the +# LogLevel was set to Warning, then all log messages from Warning to +# Critical would be output, but Notice and below would be suppressed. +# +LogLevel Info + +# +# PidFile: Write the PID of the main tinyproxy thread to this file so it +# can be used for signalling purposes. +# +#PidFile "/var/run/tinyproxy/tinyproxy.pid" + +# +# XTinyproxy: Tell Tinyproxy to include the X-Tinyproxy header, which +# contains the client's IP address. +# +#XTinyproxy Yes + +# +# Upstream: +# +# Turns on upstream proxy support. +# +# The upstream rules allow you to selectively route upstream connections +# based on the host/domain of the site being accessed. +# +# For example: +# # connection to test domain goes through testproxy +# upstream testproxy:8008 ".test.domain.invalid" +# upstream testproxy:8008 ".our_testbed.example.com" +# upstream testproxy:8008 "192.168.128.0/255.255.254.0" +# +# # no upstream proxy for internal websites and unqualified hosts +# no upstream ".internal.example.com" +# no upstream "www.example.com" +# no upstream "10.0.0.0/8" +# no upstream "192.168.0.0/255.255.254.0" +# no upstream "." +# +# # connection to these boxes go through their DMZ firewalls +# upstream cust1_firewall:8008 "testbed_for_cust1" +# upstream cust2_firewall:8008 "testbed_for_cust2" +# +# # default upstream is internet firewall +# upstream firewall.internal.example.com:80 +# +# The LAST matching rule wins the route decision. As you can see, you +# can use a host, or a domain: +# name matches host exactly +# .name matches any host in domain "name" +# . matches any host with no domain (in 'empty' domain) +# IP/bits matches network/mask +# IP/mask matches network/mask +# +#Upstream some.remote.proxy:port + +# +# MaxClients: This is the absolute highest number of threads which will +# be created. In other words, only MaxClients number of clients can be +# connected at the same time. +# +MaxClients 100 + +# +# MinSpareServers/MaxSpareServers: These settings set the upper and +# lower limit for the number of spare servers which should be available. +# +# If the number of spare servers falls below MinSpareServers then new +# server processes will be spawned. If the number of servers exceeds +# MaxSpareServers then the extras will be killed off. +# +MinSpareServers 5 +MaxSpareServers 20 + +# +# StartServers: The number of servers to start initially. +# +StartServers 10 + +# +# MaxRequestsPerChild: The number of connections a thread will handle +# before it is killed. In practise this should be set to 0, which +# disables thread reaping. If you do notice problems with memory +# leakage, then set this to something like 10000. +# +MaxRequestsPerChild 0 + +# +# Allow: Customization of authorization controls. If there are any +# access control keywords then the default action is to DENY. Otherwise, +# the default action is ALLOW. +# +# The order of the controls are important. All incoming connections are +# tested against the controls based on order. +# +# Allow 127.0.0.1 + +# +# AddHeader: Adds the specified headers to outgoing HTTP requests that +# Tinyproxy makes. Note that this option will not work for HTTPS +# traffic, as Tinyproxy has no control over what headers are exchanged. +# +#AddHeader "X-My-Header" "Powered by Tinyproxy" + +# +# ViaProxyName: The "Via" header is required by the HTTP RFC, but using +# the real host name is a security concern. If the following directive +# is enabled, the string supplied will be used as the host name in the +# Via header; otherwise, the server's host name will be used. +# +ViaProxyName "tinyproxy" + +# +# DisableViaHeader: When this is set to yes, Tinyproxy does NOT add +# the Via header to the requests. This virtually puts Tinyproxy into +# stealth mode. Note that RFC 2616 requires proxies to set the Via +# header, so by enabling this option, you break compliance. +# Don't disable the Via header unless you know what you are doing... +# +#DisableViaHeader Yes + +# +# Filter: This allows you to specify the location of the filter file. +# +#Filter "/etc/tinyproxy/filter" + +# +# FilterURLs: Filter based on URLs rather than domains. +# +#FilterURLs On + +# +# FilterExtended: Use POSIX Extended regular expressions rather than +# basic. +# +#FilterExtended On + +# +# FilterCaseSensitive: Use case sensitive regular expressions. +# +#FilterCaseSensitive On + +# +# FilterDefaultDeny: Change the default policy of the filtering system. +# If this directive is commented out, or is set to "No" then the default +# policy is to allow everything which is not specifically denied by the +# filter file. +# +# However, by setting this directive to "Yes" the default policy becomes +# to deny everything which is _not_ specifically allowed by the filter +# file. +# +#FilterDefaultDeny Yes + +# +# Anonymous: If an Anonymous keyword is present, then anonymous proxying +# is enabled. The headers listed are allowed through, while all others +# are denied. If no Anonymous keyword is present, then all headers are +# allowed through. You must include quotes around the headers. +# +# Most sites require cookies to be enabled for them to work correctly, so +# you will need to allow Cookies through if you access those sites. +# +#Anonymous "Host" +#Anonymous "Authorization" +#Anonymous "Cookie" + +# +# ConnectPort: This is a list of ports allowed by tinyproxy when the +# CONNECT method is used. To disable the CONNECT method altogether, set +# the value to 0. If no ConnectPort line is found, all ports are +# allowed (which is not very secure.) +# +# The following two ports are used by SSL. +# +ConnectPort 443 +ConnectPort 563 + +# +# Configure one or more ReversePath directives to enable reverse proxy +# support. With reverse proxying it's possible to make a number of +# sites appear as if they were part of a single site. +# +# If you uncomment the following two directives and run tinyproxy +# on your own computer at port 8888, you can access Google using +# http://localhost:8888/google/ and Wired News using +# http://localhost:8888/wired/news/. Neither will actually work +# until you uncomment ReverseMagic as they use absolute linking. +# +#ReversePath "/google/" "http://www.google.com/" +#ReversePath "/wired/" "http://www.wired.com/" + +# +# When using tinyproxy as a reverse proxy, it is STRONGLY recommended +# that the normal proxy is turned off by uncommenting the next directive. +# +#ReverseOnly Yes + +# +# Use a cookie to track reverse proxy mappings. If you need to reverse +# proxy sites which have absolute links you must uncomment this. +# +#ReverseMagic Yes + +# +# The URL that's used to access this reverse proxy. The URL is used to +# rewrite HTTP redirects so that they won't escape the proxy. If you +# have a chain of reverse proxies, you'll need to put the outermost +# URL here (the address which the end user types into his/her browser). +# +# If not set then no rewriting occurs. +# +#ReverseBaseURL "http://localhost:8888/" diff --git a/dev-environments/listen-tls/Makefile b/dev-environments/listen-tls/Makefile new file mode 100644 index 000000000..fe6780662 --- /dev/null +++ b/dev-environments/listen-tls/Makefile @@ -0,0 +1,18 @@ +SHELL = /usr/bin/env bash -o pipefail +.SHELLFLAGS = -ec +.DEFAULT_GOAL := gateway +MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +WORKDIR := $(patsubst %/,%,$(dir $(MKFILE_PATH))) +DOCKER ?= $(shell which docker 2> /dev/null || echo "docker") + +gateway: ## run gateway configured to access upstream powered with TLS + $(DOCKER) compose -f docker-compose.yml run --service-ports gateway + +clean: + $(DOCKER) compose down --volumes --remove-orphans + $(DOCKER) compose -f docker-compose.yml down --volumes --remove-orphans + +certs: + $(MAKE) clean -C $(WORKDIR)/cert -f $(WORKDIR)/cert/Makefile + $(MAKE) ca -C $(WORKDIR)/cert -f $(WORKDIR)/cert/Makefile + $(MAKE) clientcerts -C $(WORKDIR)/cert -f $(WORKDIR)/cert/Makefile DOMAIN=example.com diff --git a/dev-environments/listen-tls/README.md b/dev-environments/listen-tls/README.md new file mode 100644 index 000000000..bca33ef59 --- /dev/null +++ b/dev-environments/listen-tls/README.md @@ -0,0 +1,33 @@ +# Making APIcast listen on HTTPS + +## Create the SSL Certificates + +```sh +make certs +``` + +## Run the gateway + +Running local `apicast-test` docker image + +```sh +make gateway +``` + +Running custom apicast image + +```sh +make gateway IMAGE_NAME=quay.io/3scale/apicast:latest +``` + +## Testing + +```sh +curl --resolve example.com:8443:127.0.0.1 -v --cacert cert/rootCA.pem "https://example.com:8443/?user_key=123" +``` + +## Clean env + +```sh +make clean +``` diff --git a/dev-environments/listen-tls/apicast-config.json b/dev-environments/listen-tls/apicast-config.json new file mode 100644 index 000000000..06014cab0 --- /dev/null +++ b/dev-environments/listen-tls/apicast-config.json @@ -0,0 +1,31 @@ +{ + "services": [ + { + "id": "1", + "backend_version": "1", + "proxy": { + "hosts": ["example.com"], + "api_backend": "http://one.upstream/get", + "backend": { + "endpoint": "http://127.0.0.1:8081", + "host": "backend" + }, + "policy_chain": [ + { + "name": "apicast.policy.apicast" + } + ], + "proxy_rules": [ + { + "http_method": "GET", + "pattern": "/", + "metric_system_name": "hits", + "delta": 1, + "parameters": [], + "querystring_parameters": {} + } + ] + } + } + ] +} diff --git a/dev-environments/listen-tls/cert/Makefile b/dev-environments/listen-tls/cert/Makefile new file mode 100644 index 000000000..1739aa70b --- /dev/null +++ b/dev-environments/listen-tls/cert/Makefile @@ -0,0 +1,15 @@ +clean: + - rm *.crt *.key *.pem *.csr + +ca: + openssl genrsa -out rootCA.key 2048 + openssl req -batch -new -x509 -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem + +clientcerts: + openssl req -subj '/CN=$(DOMAIN)' -newkey rsa:4096 -nodes \ + -sha256 \ + -days 3650 \ + -keyout $(DOMAIN).key \ + -out $(DOMAIN).csr + chmod +r $(DOMAIN).key + openssl x509 -req -in $(DOMAIN).csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out $(DOMAIN).crt -days 500 -sha256 diff --git a/dev-environments/listen-tls/docker-compose.yml b/dev-environments/listen-tls/docker-compose.yml new file mode 100644 index 000000000..723f71886 --- /dev/null +++ b/dev-environments/listen-tls/docker-compose.yml @@ -0,0 +1,38 @@ +--- +version: '3.8' +services: + gateway: + image: ${IMAGE_NAME:-apicast-test} + depends_on: + - one.upstream + - two.upstream + environment: + APICAST_HTTPS_PORT: 8443 + APICAST_HTTPS_CERTIFICATE: /var/run/secrets/apicast/example.com.crt + APICAST_HTTPS_CERTIFICATE_KEY: /var/run/secrets/apicast/example.com.key + THREESCALE_CONFIG_FILE: /tmp/config.json + THREESCALE_DEPLOYMENT_ENV: staging + APICAST_CONFIGURATION_LOADER: lazy + APICAST_WORKERS: 1 + APICAST_LOG_LEVEL: debug + APICAST_CONFIGURATION_CACHE: "0" + expose: + - "8443" + - "8090" + ports: + - "8443:8443" + - "8090:8090" + volumes: + - ./apicast-config.json:/tmp/config.json + - ./cert:/var/run/secrets/apicast + one.upstream: + image: alpine/socat:1.7.4.4 + container_name: one.upstream + command: "-d -v -d TCP-LISTEN:80,reuseaddr,fork TCP:two.upstream:80" + expose: + - "80" + restart: unless-stopped + two.upstream: + image: kennethreitz/httpbin + expose: + - "80" diff --git a/dev-environments/opentelemetry-instrumented-gateway/Makefile b/dev-environments/opentelemetry-instrumented-gateway/Makefile new file mode 100644 index 000000000..7e0707631 --- /dev/null +++ b/dev-environments/opentelemetry-instrumented-gateway/Makefile @@ -0,0 +1,13 @@ +SHELL = /usr/bin/env bash -o pipefail +.SHELLFLAGS = -ec +.DEFAULT_GOAL := gateway +MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +WORKDIR := $(patsubst %/,%,$(dir $(MKFILE_PATH))) +DOCKER ?= $(shell which docker 2> /dev/null || echo "docker") + +gateway: ## run gateway configured to access plain HTTP 1.1 upstream + $(DOCKER) compose -f docker-compose.yml run --service-ports gateway + +clean: + $(DOCKER) compose down --volumes --remove-orphans + $(DOCKER) compose -f docker-compose.yml down --volumes --remove-orphans diff --git a/dev-environments/opentelemetry-instrumented-gateway/README.md b/dev-environments/opentelemetry-instrumented-gateway/README.md new file mode 100644 index 000000000..abf168825 --- /dev/null +++ b/dev-environments/opentelemetry-instrumented-gateway/README.md @@ -0,0 +1,51 @@ +# Gateway instrumented with opentelemetry + +APIcast (opentelemetry) --> upstream plain HTTP 1.1 upstream + +APIcast configured with plain HTTP 1.1 upstream server equipped with traffic rely agent (socat) + +## Run the gateway + +Running local `apicast-test` docker image + +```sh +make gateway +``` + +Running custom apicast image + +```sh +make gateway IMAGE_NAME=quay.io/3scale/apicast:latest +``` + +Traffic between the proxy and upstream can be inspected looking at logs from `example.com` service + +``` +docker compose -p opentelemetry-instrumented-gateway logs -f example.com +``` + +Open in local browser jaeger dashboard + +``` +http://127.0.0.1:16686/search +``` + +## Testing + +`GET` request + +```sh +curl --resolve get.example.com:8080:127.0.0.1 -v "http://get.example.com:8080/?user_key=123" +``` + +`POST` request + +```sh +curl --resolve post.example.com:8080:127.0.0.1 -v -X POST "http://post.example.com:8080/?user_key=123" +``` + +## Clean env + +```sh +make clean +``` diff --git a/dev-environments/opentelemetry-instrumented-gateway/apicast-config.json b/dev-environments/opentelemetry-instrumented-gateway/apicast-config.json new file mode 100644 index 000000000..30c2db396 --- /dev/null +++ b/dev-environments/opentelemetry-instrumented-gateway/apicast-config.json @@ -0,0 +1,58 @@ +{ + "services": [ + { + "id": "1", + "backend_version": "1", + "proxy": { + "hosts": ["get.example.com"], + "api_backend": "http://example.com/get", + "backend": { + "endpoint": "http://127.0.0.1:8081", + "host": "backend" + }, + "policy_chain": [ + { + "name": "apicast.policy.apicast" + } + ], + "proxy_rules": [ + { + "http_method": "GET", + "pattern": "/", + "metric_system_name": "hits", + "delta": 1, + "parameters": [], + "querystring_parameters": {} + } + ] + } + }, + { + "id": "2", + "backend_version": "1", + "proxy": { + "hosts": ["post.example.com"], + "api_backend": "http://example.com/post", + "backend": { + "endpoint": "http://127.0.0.1:8081", + "host": "backend" + }, + "policy_chain": [ + { + "name": "apicast.policy.apicast" + } + ], + "proxy_rules": [ + { + "http_method": "POST", + "pattern": "/", + "metric_system_name": "hits", + "delta": 1, + "parameters": [], + "querystring_parameters": {} + } + ] + } + } + ] +} diff --git a/dev-environments/opentelemetry-instrumented-gateway/docker-compose.yml b/dev-environments/opentelemetry-instrumented-gateway/docker-compose.yml new file mode 100644 index 000000000..f9e3b760c --- /dev/null +++ b/dev-environments/opentelemetry-instrumented-gateway/docker-compose.yml @@ -0,0 +1,47 @@ +--- +version: '3.8' +services: + gateway: + image: ${IMAGE_NAME:-apicast-test} + depends_on: + - jaeger + - example.com + - two.upstream + environment: + THREESCALE_CONFIG_FILE: /tmp/config.json + THREESCALE_DEPLOYMENT_ENV: staging + APICAST_CONFIGURATION_LOADER: lazy + APICAST_WORKERS: 1 + APICAST_LOG_LEVEL: debug + APICAST_CONFIGURATION_CACHE: "0" + OPENTELEMETRY: "1" + OPENTELEMETRY_CONFIG: /opt/app-root/src/tracing-configs/otel.toml + expose: + - "8080" + - "8090" + ports: + - "8080:8080" + - "8090:8090" + volumes: + - ./apicast-config.json:/tmp/config.json + - ./otel.toml:/opt/app-root/src/tracing-configs/otel.toml + example.com: + image: alpine/socat:1.7.4.4 + container_name: example.com + command: "-d -v -d TCP-LISTEN:80,reuseaddr,fork TCP:two.upstream:80" + expose: + - "80" + restart: unless-stopped + two.upstream: + image: kennethreitz/httpbin + expose: + - "80" + jaeger: + image: jaegertracing/all-in-one:latest + environment: + JAEGER_DISABLED: "false" + COLLECTOR_OTLP_ENABLED: "true" + ports: + - 16686:16686 + expose: + - "4317" diff --git a/examples/opentelemetry/otel.toml b/dev-environments/opentelemetry-instrumented-gateway/otel.toml similarity index 100% rename from examples/opentelemetry/otel.toml rename to dev-environments/opentelemetry-instrumented-gateway/otel.toml diff --git a/dev-environments/plain-http-upstream/Makefile b/dev-environments/plain-http-upstream/Makefile new file mode 100644 index 000000000..7e0707631 --- /dev/null +++ b/dev-environments/plain-http-upstream/Makefile @@ -0,0 +1,13 @@ +SHELL = /usr/bin/env bash -o pipefail +.SHELLFLAGS = -ec +.DEFAULT_GOAL := gateway +MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +WORKDIR := $(patsubst %/,%,$(dir $(MKFILE_PATH))) +DOCKER ?= $(shell which docker 2> /dev/null || echo "docker") + +gateway: ## run gateway configured to access plain HTTP 1.1 upstream + $(DOCKER) compose -f docker-compose.yml run --service-ports gateway + +clean: + $(DOCKER) compose down --volumes --remove-orphans + $(DOCKER) compose -f docker-compose.yml down --volumes --remove-orphans diff --git a/dev-environments/plain-http-upstream/README.md b/dev-environments/plain-http-upstream/README.md new file mode 100644 index 000000000..68290d8a6 --- /dev/null +++ b/dev-environments/plain-http-upstream/README.md @@ -0,0 +1,45 @@ +# Plain HTTP 1.1 upstream + +APIcast --> upstream plain HTTP 1.1 upstream + +APIcast configured with plain HTTP 1.1 upstream server equipped with traffic rely agent (socat) + +## Run the gateway + +Running local `apicast-test` docker image + +```sh +make gateway +``` + +Running custom apicast image + +```sh +make gateway IMAGE_NAME=quay.io/3scale/apicast:latest +``` + +Traffic between the proxy and upstream can be inspected looking at logs from `example.com` service + +``` +docker compose -p plain-http-upstream logs -f example.com +``` + +## Testing + +`GET` request + +```sh +curl --resolve get.example.com:8080:127.0.0.1 -v "http://get.example.com:8080/?user_key=123" +``` + +`POST` request + +```sh +curl --resolve post.example.com:8080:127.0.0.1 -v -X POST "http://post.example.com:8080/?user_key=123" +``` + +## Clean env + +```sh +make clean +``` diff --git a/dev-environments/plain-http-upstream/apicast-config.json b/dev-environments/plain-http-upstream/apicast-config.json new file mode 100644 index 000000000..30c2db396 --- /dev/null +++ b/dev-environments/plain-http-upstream/apicast-config.json @@ -0,0 +1,58 @@ +{ + "services": [ + { + "id": "1", + "backend_version": "1", + "proxy": { + "hosts": ["get.example.com"], + "api_backend": "http://example.com/get", + "backend": { + "endpoint": "http://127.0.0.1:8081", + "host": "backend" + }, + "policy_chain": [ + { + "name": "apicast.policy.apicast" + } + ], + "proxy_rules": [ + { + "http_method": "GET", + "pattern": "/", + "metric_system_name": "hits", + "delta": 1, + "parameters": [], + "querystring_parameters": {} + } + ] + } + }, + { + "id": "2", + "backend_version": "1", + "proxy": { + "hosts": ["post.example.com"], + "api_backend": "http://example.com/post", + "backend": { + "endpoint": "http://127.0.0.1:8081", + "host": "backend" + }, + "policy_chain": [ + { + "name": "apicast.policy.apicast" + } + ], + "proxy_rules": [ + { + "http_method": "POST", + "pattern": "/", + "metric_system_name": "hits", + "delta": 1, + "parameters": [], + "querystring_parameters": {} + } + ] + } + } + ] +} diff --git a/docker-compose.upstream-tls.yml b/dev-environments/plain-http-upstream/docker-compose.yml similarity index 53% rename from docker-compose.upstream-tls.yml rename to dev-environments/plain-http-upstream/docker-compose.yml index 94fe05f93..7e671800a 100644 --- a/docker-compose.upstream-tls.yml +++ b/dev-environments/plain-http-upstream/docker-compose.yml @@ -4,7 +4,8 @@ services: gateway: image: ${IMAGE_NAME:-apicast-test} depends_on: - - one.upstream + - example.com + - two.upstream environment: THREESCALE_CONFIG_FILE: /tmp/config.json THREESCALE_DEPLOYMENT_ENV: staging @@ -19,12 +20,15 @@ services: - "8080:8080" - "8090:8090" volumes: - - ./examples/tlsv1.3-upstream/apicast-config.json:/tmp/config.json - one.upstream: - image: nginx:1.23.4 + - ./apicast-config.json:/tmp/config.json + example.com: + image: alpine/socat:1.7.4.4 + container_name: example.com + command: "-d -v -d TCP-LISTEN:80,reuseaddr,fork TCP:two.upstream:80" expose: - - "443" - volumes: - - ./examples/tlsv1.3-upstream/proxy-nginx.conf:/etc/nginx/nginx.conf - - ./examples/tlsv1.3-upstream/upstream-cert/one.upstream.key:/etc/pki/tls.key - - ./examples/tlsv1.3-upstream/upstream-cert/one.upstream.crt:/etc/pki/tls.crt + - "80" + restart: unless-stopped + two.upstream: + image: kennethreitz/httpbin + expose: + - "80" diff --git a/dev-environments/upstream-tlsv1.3/Makefile b/dev-environments/upstream-tlsv1.3/Makefile new file mode 100644 index 000000000..fe6780662 --- /dev/null +++ b/dev-environments/upstream-tlsv1.3/Makefile @@ -0,0 +1,18 @@ +SHELL = /usr/bin/env bash -o pipefail +.SHELLFLAGS = -ec +.DEFAULT_GOAL := gateway +MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +WORKDIR := $(patsubst %/,%,$(dir $(MKFILE_PATH))) +DOCKER ?= $(shell which docker 2> /dev/null || echo "docker") + +gateway: ## run gateway configured to access upstream powered with TLS + $(DOCKER) compose -f docker-compose.yml run --service-ports gateway + +clean: + $(DOCKER) compose down --volumes --remove-orphans + $(DOCKER) compose -f docker-compose.yml down --volumes --remove-orphans + +certs: + $(MAKE) clean -C $(WORKDIR)/cert -f $(WORKDIR)/cert/Makefile + $(MAKE) ca -C $(WORKDIR)/cert -f $(WORKDIR)/cert/Makefile + $(MAKE) clientcerts -C $(WORKDIR)/cert -f $(WORKDIR)/cert/Makefile DOMAIN=example.com diff --git a/dev-environments/upstream-tlsv1.3/README.md b/dev-environments/upstream-tlsv1.3/README.md new file mode 100644 index 000000000..b2da7e763 --- /dev/null +++ b/dev-environments/upstream-tlsv1.3/README.md @@ -0,0 +1,51 @@ +# Upstream using TLSv1.3 + +APIcast --> upstream (TLSv1.3) + +APIcast configured with TLSv1.3 powered upstream . TLS termination endpoint is `socat`. + +## Create the SSL Certificates + +```sh +make certs +``` + +## Run the gateway + +Running local `apicast-test` docker image + +```sh +make gateway +``` + +Running custom apicast image + +```sh +make gateway IMAGE_NAME=quay.io/3scale/apicast:latest +``` + +Traffic between the gateway and upstream can be inspected looking at logs from `example.com` service + +``` +docker compose -p upstream-tlsv13 logs -f example.com +``` + +## Testing + +`GET` request + +```sh +curl --resolve get.example.com:8080:127.0.0.1 -v "http://get.example.com:8080/?user_key=123" +``` + +`POST` request + +```sh +curl --resolve post.example.com:8080:127.0.0.1 -v -X POST "http://post.example.com:8080/?user_key=123" +``` + +## Clean env + +```sh +make clean +``` diff --git a/dev-environments/upstream-tlsv1.3/apicast-config.json b/dev-environments/upstream-tlsv1.3/apicast-config.json new file mode 100644 index 000000000..f6f2c5923 --- /dev/null +++ b/dev-environments/upstream-tlsv1.3/apicast-config.json @@ -0,0 +1,58 @@ +{ + "services": [ + { + "id": "1", + "backend_version": "1", + "proxy": { + "hosts": ["get.example.com"], + "api_backend": "https://example.com/get", + "backend": { + "endpoint": "http://127.0.0.1:8081", + "host": "backend" + }, + "policy_chain": [ + { + "name": "apicast.policy.apicast" + } + ], + "proxy_rules": [ + { + "http_method": "GET", + "pattern": "/", + "metric_system_name": "hits", + "delta": 1, + "parameters": [], + "querystring_parameters": {} + } + ] + } + }, + { + "id": "2", + "backend_version": "1", + "proxy": { + "hosts": ["post.example.com"], + "api_backend": "https://example.com/post", + "backend": { + "endpoint": "http://127.0.0.1:8081", + "host": "backend" + }, + "policy_chain": [ + { + "name": "apicast.policy.apicast" + } + ], + "proxy_rules": [ + { + "http_method": "POST", + "pattern": "/", + "metric_system_name": "hits", + "delta": 1, + "parameters": [], + "querystring_parameters": {} + } + ] + } + } + ] +} diff --git a/dev-environments/upstream-tlsv1.3/cert/Makefile b/dev-environments/upstream-tlsv1.3/cert/Makefile new file mode 100644 index 000000000..e9efe9b61 --- /dev/null +++ b/dev-environments/upstream-tlsv1.3/cert/Makefile @@ -0,0 +1,16 @@ +clean: + - rm *.crt *.key *.pem *.csr + +ca: + openssl genrsa -out rootCA.key 2048 + openssl req -batch -new -x509 -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem + +clientcerts: + openssl req -subj '/CN=$(DOMAIN)' -newkey rsa:4096 -nodes \ + -sha256 \ + -days 3650 \ + -keyout $(DOMAIN).key \ + -out $(DOMAIN).csr + chmod +r $(DOMAIN).key + openssl x509 -req -in $(DOMAIN).csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out $(DOMAIN).crt -days 500 -sha256 + cat $(DOMAIN).key $(DOMAIN).crt >$(DOMAIN).pem diff --git a/dev-environments/upstream-tlsv1.3/docker-compose.yml b/dev-environments/upstream-tlsv1.3/docker-compose.yml new file mode 100644 index 000000000..33061e8a8 --- /dev/null +++ b/dev-environments/upstream-tlsv1.3/docker-compose.yml @@ -0,0 +1,36 @@ +--- +version: '3.8' +services: + gateway: + image: ${IMAGE_NAME:-apicast-test} + depends_on: + - example.com + - two.upstream + environment: + THREESCALE_CONFIG_FILE: /tmp/config.json + THREESCALE_DEPLOYMENT_ENV: staging + APICAST_CONFIGURATION_LOADER: lazy + APICAST_WORKERS: 1 + APICAST_LOG_LEVEL: debug + APICAST_CONFIGURATION_CACHE: "0" + expose: + - "8080" + - "8090" + ports: + - "8080:8080" + - "8090:8090" + volumes: + - ./apicast-config.json:/tmp/config.json + example.com: + image: alpine/socat:1.7.4.4 + container_name: example.com + command: "-v openssl-listen:443,reuseaddr,fork,cert=/etc/pki/example.com.pem,verify=0,openssl-min-proto-version=TLS1.3,openssl-max-proto-version=TLS1.3 TCP:two.upstream:80" + expose: + - "443" + restart: unless-stopped + volumes: + - ./cert/example.com.pem:/etc/pki/example.com.pem + two.upstream: + image: kennethreitz/httpbin + expose: + - "80" diff --git a/docker-compose.yml b/docker-compose.yml index ef00eb3be..300f8c93f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -69,21 +69,6 @@ services: volumes: - ./examples/opentracing/apicast-config.json:/tmp/config.json - ./examples/opentracing/jaeger-config.json:/opt/app-root/src/tracing-configs/tracing-config-jaeger-jaeger-config.json - opentelemetry-instrumented-gateway: - image: ${IMAGE_NAME:-apicast-test} - depends_on: - - jaeger - environment: - THREESCALE_CONFIG_FILE: /tmp/config.json - THREESCALE_DEPLOYMENT_ENV: staging - APICAST_CONFIGURATION_LOADER: lazy - APICAST_LOG_LEVEL: debug - APICAST_CONFIGURATION_CACHE: "0" - OPENTELEMETRY: "1" - OPENTELEMETRY_CONFIG: /opt/app-root/src/tracing-configs/otel.toml - volumes: - - ./examples/opentelemetry/apicast-config.json:/tmp/config.json - - ./examples/opentelemetry/otel.toml:/opt/app-root/src/tracing-configs/otel.toml jaeger: image: jaegertracing/all-in-one:latest environment: diff --git a/examples/forward-proxy/README.md b/examples/forward-proxy/README.md deleted file mode 100644 index 68fd9899f..000000000 --- a/examples/forward-proxy/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# PROXY with upstream using TLSv1.3 - -APIcast --> tiny proxy (connect to 443 but no cert installed) --> upstream (TLSv1.3) - -APicast starts SSL tunnel (via HTTP Connect method) against proxy to access upstream configured with TLSv1.3 - -``` -curl -v -H "Host: one" http://${APICAST_IP}:8080/get?user_key=foo -``` diff --git a/examples/forward-proxy/apicast-config.json b/examples/forward-proxy/apicast-config.json deleted file mode 100644 index 63298bd41..000000000 --- a/examples/forward-proxy/apicast-config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "services": [ - { - "backend_version": "1", - "proxy": { - "hosts": ["one"], - "api_backend": "https://upstream:443/", - "backend": { - "endpoint": "http://127.0.0.1:8081", - "host": "backend" - }, - "policy_chain": [ - { - "name": "apicast.policy.apicast" - }, - { - "name": "apicast.policy.http_proxy", - "configuration": { - "https_proxy": "http://proxy:443/" - } - } - ], - "proxy_rules": [ - { - "http_method": "GET", - "pattern": "/", - "metric_system_name": "hits", - "delta": 1, - "parameters": [], - "querystring_parameters": {} - } - ] - } - } - ] -} diff --git a/examples/forward-proxy/proxy-nginx.conf b/examples/forward-proxy/proxy-nginx.conf deleted file mode 100644 index 3809958e4..000000000 --- a/examples/forward-proxy/proxy-nginx.conf +++ /dev/null @@ -1,27 +0,0 @@ -worker_processes auto; - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - -events { worker_connections 1024; } - -http { - server { - listen 443 ssl; - - server_name upstream; - - resolver 8.8.8.8; - - access_log /dev/stdout; - error_log /dev/stdout info; - - ssl_certificate /etc/pki/tls.crt; - ssl_certificate_key /etc/pki/tls.key; - ssl_protocols TLSv1.3; - - location ~ ^/(.*)$ { - proxy_pass https://postman-echo.com/get/$1$is_args$args; - } - } -} diff --git a/examples/forward-proxy/upstream-cert/upstream.crt b/examples/forward-proxy/upstream-cert/upstream.crt deleted file mode 100644 index a88a1381d..000000000 --- a/examples/forward-proxy/upstream-cert/upstream.crt +++ /dev/null @@ -1,23 +0,0 @@ ------BEGIN CERTIFICATE----- -MIID0TCCArmgAwIBAgIUVLuR+puDZ8IZ2IdWZlBmeNSLW0UwDQYJKoZIhvcNAQEL -BQAweDELMAkGA1UEBhMCRVMxEjAQBgNVBAgMCUJhcmNlbG9uYTESMBAGA1UEBwwJ -QmFyY2Vsb25hMR0wGwYDVQQKDBRSSC0zc2NhbGUtRGV2dGVzdGluZzEPMA0GA1UE -CwwGM3NjYWxlMREwDwYDVQQDDAh1cHN0cmVhbTAeFw0yMzAzMzEwODE2MzVaFw0z -MzAzMjgwODE2MzVaMHgxCzAJBgNVBAYTAkVTMRIwEAYDVQQIDAlCYXJjZWxvbmEx -EjAQBgNVBAcMCUJhcmNlbG9uYTEdMBsGA1UECgwUUkgtM3NjYWxlLURldnRlc3Rp -bmcxDzANBgNVBAsMBjNzY2FsZTERMA8GA1UEAwwIdXBzdHJlYW0wggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDE5pVWHIECIcA9BiKN6LZjg7qAl/BAediR -WOHtzksE96Y3pMtQcI8qQcExu4cbrJyc0O2C/wvsyhi0giAhMPLJlFjBcpIOhapH -nc1ZIgYW/mIzPp+lS0HBrZj6SJef/83DIkou1tv8DOnDtrUHH2o1FtB/PTkGlfh2 -oyNe75ZjG82DU8ToKIvJLmhc094XQIes7qRnbd/miBwLyvnOFeQoHQzcuaX1Of2c -Q4VJlNsQwxFLdaN/Xd1zCMLL0t/XhQvKS8ofQFd9ySDbzfuB59NV5aUatM3hcNbL -ieUMPHCisyvuO36O2ZpnsAcN5aMaHZ4xAHTzpfuSwfUotFnoTpdhAgMBAAGjUzBR -MB0GA1UdDgQWBBTSz08QUrGbnVKWJEkeFF7kSdEt4jAfBgNVHSMEGDAWgBTSz08Q -UrGbnVKWJEkeFF7kSdEt4jAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUA -A4IBAQBUNHY1dXQlfLpfrVeMtJbSIPkpZPcjPmEJlS9whrqs1739IZcgs1W3LEb/ -LOYUZyctV7CC1aXQkYqrEvTQ/IMJe4ui+gwz2Gas+lfh6JLjnAPazlMfPoHzhypG -8GDo9+xwTkOqX4oOJBhdiNeAbOCCFdGPIyMO4Tb7Knc60APPjqc/jA+z9xA9E2wY -Pv1WDqPuL8c+a6lzvuj1oEFwrIgZzjxZ0Cu/MIcC0mgJJ39iSE/VAIibujB7cyMg -zw0xVEUMBOcVmvBa1E0v6m8S6FoersKiitzXxsF29s7fPYNxbA6O257wXyZnhNmr -SniQDbc9OhOyxKPbirf+DD/UIAc8 ------END CERTIFICATE----- diff --git a/examples/forward-proxy/upstream-cert/upstream.key b/examples/forward-proxy/upstream-cert/upstream.key deleted file mode 100644 index 673d68fc3..000000000 --- a/examples/forward-proxy/upstream-cert/upstream.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDE5pVWHIECIcA9 -BiKN6LZjg7qAl/BAediRWOHtzksE96Y3pMtQcI8qQcExu4cbrJyc0O2C/wvsyhi0 -giAhMPLJlFjBcpIOhapHnc1ZIgYW/mIzPp+lS0HBrZj6SJef/83DIkou1tv8DOnD -trUHH2o1FtB/PTkGlfh2oyNe75ZjG82DU8ToKIvJLmhc094XQIes7qRnbd/miBwL -yvnOFeQoHQzcuaX1Of2cQ4VJlNsQwxFLdaN/Xd1zCMLL0t/XhQvKS8ofQFd9ySDb -zfuB59NV5aUatM3hcNbLieUMPHCisyvuO36O2ZpnsAcN5aMaHZ4xAHTzpfuSwfUo -tFnoTpdhAgMBAAECggEAECZ3pk4FOOcKzRaVO/2UBDqYUBbmUmuMG3PmaCqNFbW4 -cQT31ju9SnKFRa6DiP4SBHzQlneUA1KaTygDOaW5rFYaJ5fdqgpFqsUjREXZqQYp -iNmAn766AIhcLV9J7Io/VtuXqRrfhV+Lxw1T8OcfP4aFCIK9jDA95oFAE/fj5nIL -Bw+w5SUL96q7czYta8zOjJCX8AIhsx7aScR2xYmSu7qyOS6er3+O+6MiAuj9rUD6 -j7EG2bV115TDth4RU5g32U/x0EqhQh63KhncXi96LlMK+NMicmD8LytcA8uzg4W1 -G50BTF/TCfCl7FKAMnxVdi2fvZF23om16v3SWQ6N9wKBgQDfxXVg2m63qp1cLaYL -yCZsH2C24IeNJaEm6Scy4Lv42rCC+Vv06r272uoHxobdaeFkfWQiBeYT6FmTvlSm -CIBxg3Dh0esNYSN9l4k3WDCj0UPWSqexvGsVa5nnRCLPlBUVfNg30Jf+tBdCKiDs -1JjdNI1aFd9pfH6jlxtK2geB+wKBgQDhQmT6E0z0uzbqIty8eYYNrUPNQdelM5nP -1yUAYoMsCDr9GFrE3tnENeDyvC3MlooOfxSlnAcbkjpBFXTrCB3MU928Ku2KFQdM -yoqz68/64TmqPoJAMehqkthKNb4tZJE/N5dhcR/Mt6LGy8sp/0vYp4hrmk6oX+ir -YIKu9RbpUwKBgQDOUDgQvFQoct3zBwN5CWijd6qr8ggIUxFp1r2VYy7sGnVzzITE -I0ob0ZLE6H2f1udAx3tzAw1GfYtZdLqG+n+yKQYCrpCRHWajfPu+U0lFQMPS57IF -ZTs13KdhWqjdyiJGVXzkuSXqaBCpqD4DHWBzUuigjloV3/rCyacYND2H0QKBgQCc -g2Vl3MM7yFj/lfmJe2aJWjoiA/2x64iTwQkUm15I2e8irCllYPIuQsFp5xZrcK28 -JNBTwXWu0otnbWEvbRRHRH5sn+csajAISzLUkKSRzKwkfgpCUGsMobtm1LCvGZFS -O24TZmaR94ZCWpdvNtOcVcuT+ENu+jTP3t7ucZzZwQKBgQCaHYZAV83R08nd0Mil -GKmV2MkFbWsoDCf1Z6I9h877Dpi+ilT5aX20Fv/eMpfUXCXwkciV2Yk9gtDmVJdR -emAt/f7ldcVZ1dymTZIoKTVQCXexZliISq88ZwlmHbphF8LHC/0awC4XOvsDFHmg -iAa0ukVxqPWNmpGp4wuRoa+Tpg== ------END PRIVATE KEY----- diff --git a/examples/opentelemetry/apicast-config.json b/examples/opentelemetry/apicast-config.json deleted file mode 100644 index a99361b8c..000000000 --- a/examples/opentelemetry/apicast-config.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "services": [ - { - "backend_version": "1", - "proxy": { - "hosts": ["one"], - "api_backend": "http://httpbin.org", - "backend": { - "endpoint": "http://127.0.0.1:8081", - "host": "backend" - }, - "proxy_rules": [ - { - "http_method": "GET", - "pattern": "/", - "metric_system_name": "hits", - "delta": 1, - "parameters": [], - "querystring_parameters": {} - } - ] - } - } - ] -} diff --git a/examples/tlsv1.3-upstream/README.md b/examples/tlsv1.3-upstream/README.md deleted file mode 100644 index f172e083c..000000000 --- a/examples/tlsv1.3-upstream/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# upstream using TLSv1.3 - -APIcast --> upstream (TLSv1.3) - -APicast configured to access TLSv1.3 powered upstream - -``` -curl -v -H "Host: one" http://${APICAST_IP}:8080/?user_key=foo -``` - -NOTE: using `one.upstream` as upstream hostname becase when APIcast resolves `upstream` it returns `0.0.0.1` diff --git a/examples/tlsv1.3-upstream/apicast-config.json b/examples/tlsv1.3-upstream/apicast-config.json deleted file mode 100644 index 5fef0316d..000000000 --- a/examples/tlsv1.3-upstream/apicast-config.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "services": [ - { - "backend_version": "1", - "proxy": { - "hosts": ["one"], - "api_backend": "https://one.upstream:443/", - "backend": { - "endpoint": "http://127.0.0.1:8081", - "host": "backend" - }, - "policy_chain": [ - { - "name": "apicast.policy.apicast" - } - ], - "proxy_rules": [ - { - "http_method": "GET", - "pattern": "/", - "metric_system_name": "hits", - "delta": 1, - "parameters": [], - "querystring_parameters": {} - } - ] - } - } - ] -} diff --git a/examples/tlsv1.3-upstream/proxy-nginx.conf b/examples/tlsv1.3-upstream/proxy-nginx.conf deleted file mode 100644 index 9a91348f3..000000000 --- a/examples/tlsv1.3-upstream/proxy-nginx.conf +++ /dev/null @@ -1,27 +0,0 @@ -worker_processes auto; - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - -events { worker_connections 1024; } - -http { - server { - listen 443 ssl; - - server_name one.upstream; - - resolver 8.8.8.8; - - access_log /dev/stdout; - error_log /dev/stdout info; - - ssl_certificate /etc/pki/tls.crt; - ssl_certificate_key /etc/pki/tls.key; - ssl_protocols TLSv1.3; - - location ~ ^/(.*)$ { - proxy_pass https://postman-echo.com/get/$1$is_args$args; - } - } -} diff --git a/examples/tlsv1.3-upstream/upstream-cert/one.upstream.crt b/examples/tlsv1.3-upstream/upstream-cert/one.upstream.crt deleted file mode 100644 index 77b4f39ff..000000000 --- a/examples/tlsv1.3-upstream/upstream-cert/one.upstream.crt +++ /dev/null @@ -1,23 +0,0 @@ ------BEGIN CERTIFICATE----- -MIID5TCCAs2gAwIBAgIUEW7oIi1pFN2GT/MXNPt0YfRmJBowDQYJKoZIhvcNAQEL -BQAwgYExCzAJBgNVBAYTAkVTMRIwEAYDVQQIDAlCYXJjZWxvbmExEjAQBgNVBAcM -CUJhcmNlbG9uYTEhMB8GA1UECgwYUmVkSGF0LTNzY2FsZS1EZXZ0ZXN0aW5nMRAw -DgYDVQQLDAdBUEljYXN0MRUwEwYDVQQDDAxvbmUudXBzdHJlYW0wHhcNMjMwMzMx -MDk0NjU0WhcNMzMwMzI4MDk0NjU0WjCBgTELMAkGA1UEBhMCRVMxEjAQBgNVBAgM -CUJhcmNlbG9uYTESMBAGA1UEBwwJQmFyY2Vsb25hMSEwHwYDVQQKDBhSZWRIYXQt -M3NjYWxlLURldnRlc3RpbmcxEDAOBgNVBAsMB0FQSWNhc3QxFTATBgNVBAMMDG9u -ZS51cHN0cmVhbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMWwMSy2 -Bh0fBUqHPMr3Twh29rtKTTd5V4dRHf+DAuSSS68ypMV7/SV+uMs2MXYgFTbew0sy -LfXdioMSOCHVDQqFsItKdN3SEnUhdIusWynkUID0hBW2orrkOyUW7kktL7sh5jWO -MdpB6/SyrH2j+wy2sONjEGMpFY/hJ6AaTFjhmPM8SgbzwpSAORJKVvzyCQ/Cfjt5 -cmACY6X0zijhctg6+GOYo1hQDMhU2sN4cm2fgKah+WJgQMgyZ9OwZInfOrF0guem -IOkh2jUA0N/r+m0niPaiexd0L6zhxqCMjuylRbj1ObP8gpqqWiofUcr+OrP5x4n7 -nIYgWcB3iQqUHOsCAwEAAaNTMFEwHQYDVR0OBBYEFMjravcu5CLPgA/gFdNg5cI2 -g1/zMB8GA1UdIwQYMBaAFMjravcu5CLPgA/gFdNg5cI2g1/zMA8GA1UdEwEB/wQF -MAMBAf8wDQYJKoZIhvcNAQELBQADggEBAMAOl0v4fcW8EHpCUWLeidbnc4+B+94H -5kIpa8YEETeVmVD/ZYFuEf6QgWGBydLTR0HQ/nlF+HWD+guf2n1tP5p9kJKad8nL -Kf/rurWCe8C1F+YcRkWtNZZ/IcOBmm67LoyVM1ZbrTbMcLcOPZXI/KlfIf4m1zrG -LC9QYxoZ3yjk8JKUOxHkSfyKEFhPtOMZPwI4nw7CjvjzALOYPHAGGqDdQvRC29ui -EL008p658bZlwPCD+1BDXaw2BhhN3tgbExk7RJTsEe9MEsIGpsbrNhVdho7nrq8L -QpxZc1dbljzN3NnrEy+XlPswK3gFzgcYbQTy/MdpWI8amDkWCXfu9hI= ------END CERTIFICATE----- diff --git a/examples/tlsv1.3-upstream/upstream-cert/one.upstream.key b/examples/tlsv1.3-upstream/upstream-cert/one.upstream.key deleted file mode 100644 index b5aa599f6..000000000 --- a/examples/tlsv1.3-upstream/upstream-cert/one.upstream.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDFsDEstgYdHwVK -hzzK908Idva7Sk03eVeHUR3/gwLkkkuvMqTFe/0lfrjLNjF2IBU23sNLMi313YqD -Ejgh1Q0KhbCLSnTd0hJ1IXSLrFsp5FCA9IQVtqK65DslFu5JLS+7IeY1jjHaQev0 -sqx9o/sMtrDjYxBjKRWP4SegGkxY4ZjzPEoG88KUgDkSSlb88gkPwn47eXJgAmOl -9M4o4XLYOvhjmKNYUAzIVNrDeHJtn4CmofliYEDIMmfTsGSJ3zqxdILnpiDpIdo1 -ANDf6/ptJ4j2onsXdC+s4cagjI7spUW49Tmz/IKaqloqH1HK/jqz+ceJ+5yGIFnA -d4kKlBzrAgMBAAECggEAOWG2NGM1jRhnAcYViFiW0T8uyRh9J2AKXxXVnkgZ+9zX -KSiLGWOvDEYnP50gaEhRwBaTG22aV6aRwQ/1ySQ9X9OEdjoLiCOlBejLGovR/mvu -TjArct4LiDIdVNu+GPGLzEa/usXmhJLj+agvV1zUz1DsMWSc6huPza6uQNPBW37F -DMgpm9ZTV1CF8KCGuIi4hwf3ECWMIHkFOUEKY8GMFB3oos6tLi7s4UA1DEcs6sRA -hb/NPhaOUTrrcLWyIgG66PKeNyWrnraG10nMwY1SVJg2hjael5FS5W0lw1Znihwx -8UzlSrCNNjST08TG91d/t/jF8isJEuNqDTQ74MhQ+QKBgQDLDgDeI6gOdq0MgiJv -sfdr3mLrgjeOrfngnXCatV8HN18K0YvGJz6LefQwuBrInJ5SW9ZVzijT6QU3nP8e -xAjIHUYgj0KBUR/0MkqRvbUDYG+g0Ro9J8ECOj0kVkvcplQGMuPfpUepKDnKJRIl -QHy01eWNWwtvoBtuOS29AByRzQKBgQD5O/nB7zhIO8GHK3KrB6VLF7eHho4fNCoN -QB5p/yvPlLh/fititFEhfLXRj+6ArY45UFJ0i/8q/L09n0gQlGkYCrTxRBVfLnj5 -umkAJffg3AyUQszSzKvkDfe+h9TdK4AXtcbDUDSn1ThFFZUcVjRKRZYvuk2eyhod -wbCEJrmRlwKBgQC5kI6Sc5t9vE7hA3xc/xLR7WYRO+tx5ORatQbXG7FAcwXUaTOH -Xw31gPn8HAO+GgNF2M/DkqgVIPq3nC45+4Ta/IW9864fZ/f/voYPMoNeFp9tJCsK -gG4OjxKZRpQFjat0DsXY+L7IhA5sAfzXNlvBF0i1KeMFnBf1XyPBeXyicQKBgA2+ -bvFw3auuD+gCT1p7G3RepHJGy0ORPthoNsUlmybhTqNJM99HjknIdMZPp5lU+MjU -Uxe2OKYINe9V/0VaycjXnk7HsF4FVAqBaxTlAxxVRiRO4rilLL1wv760AtsHcRLd -pU5T9/NhYK7+l7BuWIfX+oY7QdiF0JbffXpsIEOVAoGAEs6WOWr1Lu0B3hEV6bn/ -6STJc6Y3ZZo12OaebBfOquc13jcMh7CW39E2IhEb99ktE4vPFPpYWz0hdsENDP1/ -SSi6bzC2ZR9pI/1AB5UwMoh5bnL89LSkV1VjWw5J6yBW+qgS23EE/vrEkM+URFPX -jcY8wdR/FxhutjRfutgIiRQ= ------END PRIVATE KEY-----