-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
570 lines (440 loc) · 18.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>vinxi – hackable web proxy toolkit for Go</title>
<meta name="keywords" content="vinxi, proxy, toolkit, gorilla, http, http2, https, golang, go">
<meta name="description" content="Hackable web proxy toolkit for Go">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700' rel='stylesheet' type='text/css'>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="icon" type="image/png" href="/public/images/favicon.png">
<link rel="stylesheet" href="public/style.css" media="screen" charset="utf-8">
<link rel="stylesheet" href="public/syntax.css" media="screen" charset="utf-8">
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-75285480-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<header>
<div id="header-overlay"></div>
<span id="logo"></span>
<div id="menu">
<i class="material-icons">menu</i>
<ul id="menu-items">
<li><a href="#features">Features</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#components">Components</a></li>
<li><a href="#examples">Examples</a></li>
<li><a href="#cli">CLI</a></li>
<li><a href="#api">API</a></li>
<li><a href="#manager">Manager</a></li>
<li><a href="#admin-api">Admin API</a></li>
<li><a href="#admin-http-api">Admin HTTP API</a></li>
<li><a href="#authors">Authors</a></li>
<li><a href="#license">License</a></li>
<li><a href="https://github.com/vinxi/vinxi/tree/master/_examples">Examples</a></li>
<li><a href="https://github.com/vinxi/vinxi">GitHub</a></li>
</ul>
</div>
<span id="more">
<i class="material-icons">expand_more</i>
</span>
</header>
<section id="content">
<p>
vinxi is a hackable, composable, middleware-oriented web proxy toolkit written in <a href="http://golang.org">Go</a>.
</p>
<p>
vinxi was designed to build extensible and versatile web proxy solutions for a variety of purposes.
</p>
<p>
vinxi core is lightweight and relies on a component-based architecture.
It provides a generic set of built-in production-oriented <a href="#components">components</a> that are ready to plug in and use.
</p>
<p>
<b>Still beta under active development.</b>
</p>
<h1 id="features">Features</h1>
<ul>
<li>Full-featured HTTP/S proxy.</li>
<li>Modular plugin-based design.</li>
<li>Middleware-oriented supporting multiple interfaces (e.g: http.Handler, Negroni, Alice…).</li>
<li>Good interpolarity with existent middleware from the community.</li>
<li>Idiomatic built on top of <code>net/http</code>.</li>
<li>Expressive and simple programmatic API.</li>
<li>Command-line interface.</li>
<li>Declarative configuration file.</li>
<li>Admin REST API.</li>
<li>Strong plugin ecosystem (e.g: metrics, service discovery, balancer…).</li>
<li>Admin web UI (coming soon).</li>
<li>Hot-reloading. Dynamic configuration in runtime.</li>
<li>Small, hackable API and core.</li>
<li>Fast (benchmarks coming soon).</li>
<li>WebSocket proxy (beta).</li>
<li>HTTP/2 support.</li>
<li>Just Go. No third-party dependencies.</li>
<li>Official Docker image.</li>
</ul>
<h1 id="installation">Installation</h1>
<pre><code class="language-bash">go get -u gopkg.in/vinxi/vinxi.v0
</code></pre>
<h1 id="components">Components</h1>
<ul>
<li><a href="https://github.com/vinxi/mux">mux</a> - Simple, versatile and composable multiplexer for vinxi.</li>
<li><a href="https://github.com/vinxi/context">context</a> - Unobstructive context implementation for request-aware data sharing.</li>
<li><a href="https://github.com/vinxi/intercept">intercept</a> - HTTP traffic interceptor and modifier made easy.</li>
<li><a href="https://github.com/vinxi/balancer">balancer</a> - Simple traffic balancer supporting simple well-known distribution algorithms.</li>
<li><a href="https://github.com/vinxi/replay">replay</a> - Replay HTTP traffic to multiple servers.</li>
<li><a href="https://github.com/vinxi/router">router</a> - Featured, composable and fast router with hierarchical middleware layer.</li>
<li><a href="https://github.com/vinxi/forward">forward</a> - Default HTTP and WebSocket traffic forwarder.</li>
<li><a href="https://github.com/vinxi/layer">layer</a> - Default middleware layer used in vinxi ecosystem.</li>
<li><a href="https://github.com/vinxi/apachelog">apachelog</a> - Apache-style logging middleware.</li>
<li><a href="https://github.com/vinxi/consul">consul</a> - Consul service discovery provider with optional traffic balancing.</li>
<li><a href="https://github.com/vinxi/auth">auth</a> - HTTP authentication middleware supporting multiple schemes.</li>
<li><a href="https://github.com/vinxi/ratelimit">ratelimit</a> - Efficient token bucket rate limiter for your proxies.</li>
<li><a href="https://github.com/vinxi/log">log</a> - Structured, versatile, scoped logging layer.</li>
<li><a href="https://github.com/vinxi/trace">trace</a> - Structured and versatile traffic tracing instrumentation.</li>
<li><a href="https://github.com/vinxi/cors">cors</a> - W3C standard compliant full-featured CORS support.</li>
<li><a href="https://github.com/vinxi/metrics">metrics</a> - Extensible metrics instrumentation and reporting.</li>
<li><a href="https://github.com/vinxi/ip">ip</a> - IP CIDR range based filtering and multiplexer for your proxies.</li>
</ul>
<h1 id="examples">Examples</h1>
<h4 id="simple-forward-proxy">Simple forward proxy</h4>
<p>Forwards all the traffic to a specific host.</p>
<pre><code class="language-go">package main
import (
"fmt"
"gopkg.in/vinxi/vinxi.v0"
)
func main() {
vs := vinxi.NewServer(vinxi.ServerOptions{Port: 3100})
// Forward all the traffic to httpbin.org
vs.Forward("http://httpbin.org")
fmt.Printf("Server listening on port: %d\n", 3100)
err := vs.Listen()
if err != nil {
fmt.Errorf("Error: %s\n", err)
}
}
</code></pre>
<h4 id="multiplexer-composition">Multiplexer composition</h4>
<p>Uses the built-in multiplexer for traffic handling composition.</p>
<pre><code class="language-go">package main
import (
"fmt"
"net/http"
"gopkg.in/vinxi/forward.v0"
"gopkg.in/vinxi/mux.v0"
"gopkg.in/vinxi/router.v0"
"gopkg.in/vinxi/vinxi.v0"
)
func main() {
fmt.Printf("Server listening on port: %d\n", 3100)
vs := vinxi.NewServer(vinxi.ServerOptions{Host: "localhost", Port: 3100})
m := mux.New()
m.If(mux.MatchHost("localhost:3100"))
m.Use(func(w http.ResponseWriter, r *http.Request, h http.Handler) {
w.Header().Set("Server", "vinxi")
h.ServeHTTP(w, r)
})
m.Use(router.NewRoute("/foo").Handler(func(w http.ResponseWriter, req *http.Request) {
w.Write([]byte("foo bar"))
}))
m.Use(forward.To("http://127.0.0.1:8080"))
vs.Vinci.Use(m)
vs.Vinci.Forward("http://127.0.0.1")
err := vs.Listen()
if err != nil {
fmt.Errorf("Error: %s\n", err)
}
}
</code></pre>
<h4 id="simple-traffic-routing">Simple traffic routing</h4>
<p>Uses the built-in router for handle and forward traffic.</p>
<pre><code class="language-go">package main
import (
"fmt"
"net/http"
"gopkg.in/vinxi/vinxi.v0"
)
func main() {
vs := vinxi.NewServer(vinxi.ServerOptions{Host: "localhost", Port: 3100})
v := vs.Vinxi
v.Use(func(w http.ResponseWriter, r *http.Request, h http.Handler) {
w.Header().Set("Server", "vinxi")
h.ServeHTTP(w, r)
})
v.UsePhase("error", func(w http.ResponseWriter, r *http.Request, h http.Handler) {
w.Header().Set("Server", "vinxi")
w.WriteHeader(500)
w.Write([]byte("server error"))
})
v.Get("/ip").Forward("http://httpbin.org")
v.Get("/headers").Forward("http://httpbin.org")
v.Get("/image/:name").Forward("http://httpbin.org")
v.All("/post").Forward("http://httpbin.org")
v.Forward("http://example.com")
fmt.Printf("Server listening on port: %d\n", 3100)
err := vs.Listen()
if err != nil {
fmt.Errorf("Error: %s\n", err)
}
}
</code></pre>
<h1 id="cli">CLI</h1>
<p>vinxi provides a full-feateured command-line interface with a declarative configuration file capable of detailed configuration of one or multiple proxy servers.</p>
<p><strong>Note</strong>: still a work in progress.</p>
<h4 id="installation">Installation</h4>
<pre><code class="language-bash">go get -u gopkg.in/vinxi/vinxictl.v0
</code></pre>
<h4 id="usage">Usage</h4>
<pre><code class="language-bash">vinxictl 0.1.0
Usage:
vinxictl -p 80
vinxictl -p 80 -c config.toml
Options:
-a <addr> bind address [default: *]
-p <port> bind port [default: 8080]
-h, -help output help
-v, -version output version
-c, -config Config file path
-f Target server URL to forward traffic by default
-mrelease <num> OS memory release inverval in seconds [default: 30]
-cpus <num> Number of used cpu cores.
(default for current machine is 8 cores)
</code></pre>
<h1 id="api">API</h1>
<p>See <a href="https://godoc.org/github.com/vinxi/vinxi">godoc</a> to browse the self-documented API.</p>
<h1 id="manager">Manager</h1>
<p>vinxi provides the <a href="https://github.com/vinxi/vinxi/tree/master/manager">manager</a> package who has been designed to provide a both programmatic and HTTP API interfaces to manage one or multiple <code>vinxi</code> server instances.</p>
<p>For more details, see the specific manager documentation:</p>
<ul>
<li><a href="#admin-api">Programmatic API</a></li>
<li><a href="#admin-http-api">RESTful API</a></li>
</ul>
<h1 id="admin-api">Admin API</h1>
<p>vinxi provides a full-featured programmatic API to easily manage <code>vinxi</code> server instance via the <code>manager</code> package.</p>
<p>Manager programmatic API documentation is available via <a href="https://godoc.org/github.com/vinxi/vinxi/manager">godoc</a>.</p>
<h1 id="admin-http-api">Admin HTTP API</h1>
<p>vinxi comes with an internal RESTful API for administration purposes.
API commands can be run on any node, and vinxi will keep the configuration consistent and up-to-date in real time across the different vinxi server instances.</p>
<p>The RESTful Admin API server listens on port 8000 by default.</p>
<p>RESTful Admin API is part of <a href="https://github.com/vinxi/vinxi/tree/master/manager">manager</a> package. Read more about the manager <a href="#manager">here</a>.</p>
<h2 id="content-types">Content Types</h2>
<p>vinxi RESTful API is a JSON only HTTP interface.
Responses and payloads as designed to render and read JSON only data structures.</p>
<p>The MIME content type used as HTTP <code>Content-Type</code> header must be:</p>
<pre><code>application/json
</code></pre>
<h2 id="authentication">Authentication</h2>
<p>You can protect the admin HTTP API with a basic authentication mechanism.</p>
<p>Admin HTTP API is not protected by default.</p>
<h3 id="http-basic-authentication">HTTP basic authentication</h3>
<p>You can define multiple user/password credentials to authenticate users.</p>
<h2 id="endpoints">Endpoints</h2>
<h3 id="node-information">Node information</h3>
<pre><code>GET /
</code></pre>
<h5 id="response">Response</h5>
<pre><code>HTTP 200 OK
</code></pre>
<pre><code class="language-json">{
"hostname": "vinxi-server",
"version": "0.1.0",
"runtime": "go1.6",
"platform": "darwin",
"cpus": 8,
"gorutines": 13,
"links": {
"catalog": "/catalog",
"instances": "/instances",
"manager": "/manager",
"plugins": "/plugins",
"scopes": "/scopes"
}
}
</code></pre>
<h3 id="global-plugins">Global plugins</h3>
<h4 id="list-plugins">List plugins</h4>
<pre><code>GET /plugins
</code></pre>
<h5 id="response-1">Response</h5>
<pre><code class="language-json">[
{
"id": "UGEZGfua5S3U0nDS",
"name": "auth",
"description": "Authorization and authentication protection",
"config": {
"scheme": "Bearer",
"token": "s3cr3t"
}
}
]
</code></pre>
<h4 id="register-plugin">Register plugin</h4>
<pre><code>POST /plugins
</code></pre>
<h5 id="request-body">Request Body</h5>
<pre><code class="language-json">{
"name":"auth",
"config": {
"token": "s3cr3t"
}
}
</code></pre>
<h5 id="response-2">Response</h5>
<pre><code class="language-json">{
"id": "UGEZGfua5S3U0nDS",
"name": "auth",
"description": "Authorization and authentication protection",
"config": {
"scheme": "Bearer",
"token": "s3cr3t"
}
}
</code></pre>
<h4 id="get-plugin">Get plugin</h4>
<pre><code>GET /plugins/{id}
</code></pre>
<h5 id="response-3">Response</h5>
<pre><code class="language-json">{
"id": "UGEZGfua5S3U0nDS",
"name": "auth",
"description": "Authorization and authentication protection",
"config": {
"scheme": "Bearer",
"token": "s3cr3t"
}
}
</code></pre>
<h4 id="delete-plugin">Delete plugin</h4>
<pre><code>DELETE /plugins/{id}
</code></pre>
<h5 id="response-4">Response</h5>
<pre><code>HTTP 204 No Content
</code></pre>
<h3 id="instances">Instances</h3>
<h4 id="list-instances">List instances</h4>
<pre><code>GET /instances
</code></pre>
<h5 id="response-5">Response</h5>
<pre><code>HTTP 200 OK
</code></pre>
<pre><code class="language-json">[
{
"info": {
"id": "KamlJHrvH2owdzIG",
"name": "default",
"description": "This a default proxy",
"hostname": "vinxi-server",
"platform": "darwin",
"server": {
"port": 3100,
"readTimeout": 0,
"writeTimeout": 0,
"address": ""
}
},
"scopes": [
{
"id": "jd7CDZ48IsQ0RJqu",
"name": "custom",
"rules": [
{
"id": "MizprxflGgjeQe06",
"name": "path",
"description": "Matches HTTP request URL path againts a given path pattern",
"config": {
"path": "\/foo\/(.*)"
}
}
],
"plugins": [
{
"id": "AsgTHxwUgUcg9oet",
"name": "forward",
"description": "Forward HTTP traffic to remote servers",
"config": {
"url": "http:\/\/httpbin.org"
}
}
]
}
]
}
]
</code></pre>
<h4 id="get-instance">Get instance</h4>
<pre><code>GET /instances/{id}
</code></pre>
<h5 id="response-6">Response</h5>
<pre><code>HTTP 200 OK
</code></pre>
<pre><code class="language-json">{
"info": {
"id": "KamlJHrvH2owdzIG",
"name": "default",
"description": "This a default proxy",
"hostname": "test",
"platform": "darwin",
"server": {
"port": 3100,
"readTimeout": 0,
"writeTimeout": 0,
"address": ""
}
},
"scopes": [
{
"id": "jd7CDZ48IsQ0RJqu",
"name": "custom",
"rules": [
{
"id": "MizprxflGgjeQe06",
"name": "path",
"description": "Matches HTTP request URL path againts a given path pattern",
"config": {
"path": "\/foo\/(.*)"
}
}
],
"plugins": [
{
"id": "AsgTHxwUgUcg9oet",
"name": "forward",
"description": "Forward HTTP traffic to remote servers",
"config": {
"url": "http:\/\/httpbin.org"
}
}
]
}
]
}
</code></pre>
<h4 id="delete-instance">Delete instance</h4>
<pre><code>DELETE /instances/{id}
</code></pre>
<h5 id="response-7">Response</h5>
<pre><code>HTTP 204 No Content
</code></pre>
<h1 id="authors">Authors</h1>
<ul>
<li><a href="https://github.com/h2non">Tomas Aparicio</a></li>
<li><a href="https://github.com/groyoh">Yohan Robert</a></li>
</ul>
<h1 id="license">License</h1>
<p>Most is released under MIT License. Some code is under Apache License 2.0 (see specific file header for details).</p>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/languages/go.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/languages/json.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/languages/javascript.min.js"></script>
<script src="public/app.js"></script>
</body>
</html>