Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions src/envoy/prototype/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ This Proxy will use Envoy and talk to Mixer server.
go run echo.go
```

* Modify your iptables:

```
sudo iptables -t nat -A OUTPUT -p tcp --dport 9090 -j REDIRECT --to-port 9092
```

Once you are done, you should remove this rule:

```
sudo iptables -t nat -D OUTPUT -p tcp --dport 9090 -j REDIRECT --to-port 9092
```


* Start Envoy proxy, run

```
Expand Down
11 changes: 9 additions & 2 deletions src/envoy/prototype/envoy-esp.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"listeners": [
{
"port": 9092,
"bind_to_port": true,
"use_original_dst": true,
"filters": []
},
{
"port": 9090,
"bind_to_port": false,
"filters": [
{
"type": "read",
Expand All @@ -26,7 +33,7 @@
},
"access_log": [
{
"path": "/tmp/access.envoy"
"path": "/dev/stdout"
}
],
"filters": [
Expand All @@ -50,7 +57,7 @@
}
],
"admin": {
"access_log_path": "/tmp/access.envoy",
"access_log_path": "/dev/stdout",
"port": 9001
},
"cluster_manager": {
Expand Down
21 changes: 7 additions & 14 deletions test/backend/echo/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@ import (
"io/ioutil"
"net/http"
"strconv"
"sync"
"time"
)

var (
port = flag.Int("port", 8080, "default http port")

mu sync.Mutex
requests = 0
data = 0
)

func handler(w http.ResponseWriter, r *http.Request) {
fmt.Printf("%v %v %v %v\n", r.Method, r.URL, r.Proto, r.RemoteAddr)
for name, headers := range r.Header {
for _, h := range headers {
fmt.Printf("%v: %v\n", name, h)
}
}
body, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand All @@ -51,24 +54,14 @@ func handler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write(body)

mu.Lock()
requests++
data += len(body)
defer mu.Unlock()
fmt.Printf("Requests Requests: %v Data: %v\n", requests, data)
}

func main() {
flag.Parse()

go func() {
for {
mu.Lock()
fmt.Printf("Requests Requests: %v Data: %v\n", requests, data)
mu.Unlock()
time.Sleep(time.Second)
}
}()

fmt.Printf("Listening on port %v\n", *port)

http.HandleFunc("/", handler)
Expand Down