This page has been moved to https://github.com/int128/hello-envoy
This is an example of Envoy TCP Proxy from localhost:10000
to www.google.com:80
.
See also https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/listeners/tcp_proxy.
To run a proxy:
% docker run --rm getenvoy/envoy:stable --version
/usr/bin/envoy version: 1a0363c885c2dbb1e48b03847dbd706d1ba43eba/1.14.2/clean-getenvoy-fbeeb15-envoy/RELEASE/BoringSSL
% docker run --rm -p 10000:10000 -v $PWD/envoy.yaml:/envoy.yaml:ro getenvoy/envoy:stable -c /envoy.yaml
...
[2021-04-04 11:04:12.267][1][info][main] [external/envoy/source/server/server.cc:554] starting main dispatch loop
[2021-04-04 11:04:12.268][1][info][upstream] [external/envoy/source/common/upstream/cluster_manager_impl.cc:171] cm init: all clusters initialized
[2021-04-04 11:04:12.268][1][info][main] [external/envoy/source/server/server.cc:533] all clusters initialized. initializing init manager
[2021-04-04 11:04:12.270][1][info][config] [external/envoy/source/server/listener_manager_impl.cc:725] all dependencies initialized. starting workers
To connect to the remote host via the proxy:
% curl -v localhost:10000
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 10000 (#0)
> GET / HTTP/1.1
> Host: localhost:10000
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Content-Type: text/html
< Date: Sun, 04 Apr 2021 11:04:30 GMT
< Server: ECS (sjc/4E8D)
< Content-Length: 345
<
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>404 - Not Found</title>
</head>
<body>
<h1>404 - Not Found</h1>
</body>
</html>
* Connection #0 to host localhost left intact
* Closing connection 0
Note that this is an example of TCP proxy (not HTTP proxy). If you are looking for HTTP(S) proxy, see https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/http/http.
awesome!!