usb c ケーブル【1m+1m+2m+2m 4本】タイプc ケーブル Type C 3A急速充電 QC3.0対応 急速充電 PD対応 ナイロン編み 断線防止iPhone 16/15 Samsung/Note/Huawei Sony Xperia Nintendo Switch/GoPro その他Android USB-C機器対応
¥799 (2025年4月26日 13:07 GMT +09:00 時点 - 詳細はこちら価格および発送可能時期は表示された日付/時刻の時点のものであり、変更される場合があります。本商品の購入においては、購入の時点で当該の Amazon サイトに表示されている価格および発送可能時期の情報が適用されます。)USB Type C ケーブル 【1m+1m+2m+2m/4本】タイプc ケーブル PD対応 60W急速充電】データ転送 断線防止 高耐久ナイロン iPhone 16 /iPhone 15 / MacBook、iPad Pro/Air、Galaxy、Sony、Pixel Type C機種対応
¥798 (2025年4月26日 13:05 GMT +09:00 時点 - 詳細はこちら価格および発送可能時期は表示された日付/時刻の時点のものであり、変更される場合があります。本商品の購入においては、購入の時点で当該の Amazon サイトに表示されている価格および発送可能時期の情報が適用されます。)
最近OSSとして登場したAILERON Gatewayを触ってみます。
https://aileron-gateway.github.io/docs/
AILERON Gatewayは、Go言語で実装されたシンプル・軽量な汎用ゲートウェイで、Layer4, Layer7でのトラフィックルーティングや認証・認可機能などを備えているようです。
Exampleを見てみると、gRPCのプロキシなども対応している様子。
https://github.com/aileron-gateway/aileron-gateway/blob/main/_example/proxy-grpc/README.md
以下からv1.0.1のバイナリをダウンロードできるので、windows向けのバイナリを選択。
https://github.com/aileron-gateway/aileron-gateway/releases/tag/v1.0.1
https://github.com/aileron-gateway/aileron-gateway/releases/download/v1.0.1/aileron-windows-amd64.exe
他にも様々なバイナリが用意されているようです。
https://aileron-gateway.github.io/docs/installation/pre-built-binary/
ダウンロードしたバイナリは素直に動作しました。
C:optaileron>aileron-windows-amd64 -v
v1.0.1
なので、Getting StartedページのReverse Proxyのサンプルを動かしてみます。
https://aileron-gateway.github.io/docs/getting-started/reverse-proxy/
config.ymlで以下の流れの設定を定義します。
- Entrypointでリクエストを受け付けるサーバモジュール(HTTPServer)を指定
- サーバモジュールからリバースプロキシモジュール(ReverseProxyHandler)を指定
- リバースプロキシモジュールでは、アップストリームにhttp://httpbin.org を指定
自分の欲しい処理を差し込んでいく感じがシンプルで分かりやすいですね。
config.yml
apiVersion: core/v1
kind: Entrypoint
spec:
runners:
- apiVersion: core/v1
kind: HTTPServer
---
apiVersion: core/v1
kind: HTTPServer
spec:
addr: ":8080"
virtualHosts:
- handlers:
- handler:
apiVersion: core/v1
kind: ReverseProxyHandler
---
apiVersion: core/v1
kind: ReverseProxyHandler
spec:
loadBalancers:
- pathMatcher:
match: "/"
matchType: Prefix
upstreams:
- url: http://httpbin.org
上記のyamlファイルを指定して起動します。
C:optaileron>aileron-windows-amd64 -f config.yml
{"time":"2025-04-14 00:04:59","level":"INFO","msg":"server started. listening on [::]:8080","datetime":{"date":"2025-04-14","time":"00:04:59.044","zone":"Local"},"location":{"file":"httpserver/server.go","func":"httpserver.(*runner).Run","line":56}}
curlで動作確認すると問題なくアップストリームに転送されてますね。
C:optaileron>curl http://localhost:8080/get
{
"args": {},
"headers": {
"Accept": "*/*",
"Host": "httpbin.org",
"User-Agent": "curl/8.10.1",
"X-Amzn-Trace-Id": "Root=1-67fbd320-0b8a6783728059020142ef8b",
"X-Forwarded-Host": "localhost:8080"
},
"origin": "::1, XXX.XXX.XXX.XXX",
"url": "http://localhost:8080/get"
}
Design DocやExampleを見ると、OPAによる認可、流量制御、ロードバランシングなどいろいろ対応してそうなので、他のモジュールの動作も軽く試してみます。
https://aileron-gateway.github.io/aileron-gateway/app/
https://github.com/aileron-gateway/aileron-gateway/tree/main/_example
以下の構成を実現してみます。
- OPAモジュールによりGETリクエストのみ許可(policy.regoに認可ルールを記載)
- ロードバランシングモジュールによりMockbinにラウンドロビンで負荷分散
定義は以下のとおり。
(https://mockbin.io/ でそれぞれ異なる応答を返すようにしています。便利ですね..)
config.yml
apiVersion: core/v1
kind: Entrypoint
spec:
runners:
- apiVersion: core/v1
kind: HTTPServer
---
apiVersion: core/v1
kind: HTTPServer
spec:
addr: ":8080"
virtualHosts:
- middleware:
- apiVersion: app/v1
kind: OPAAuthzMiddleware
handlers:
- handler:
apiVersion: core/v1
kind: ReverseProxyHandler
---
apiVersion: app/v1
kind: OPAAuthzMiddleware
spec:
regos:
- queryParameter: "data.example.authz.allow"
policyFiles:
- ./policy.rego
---
apiVersion: core/v1
kind: ReverseProxyHandler
spec:
loadBalancers:
- pathMatcher:
match: "/"
matchType: Prefix
lbAlgorithm: RoundRobin # Use RoundRobin load balancer (Default).
upstreams:
- url: https://33549c080ed24e79899c8506960feb7b.api.mockbin.io/ #Server1
- url: https://8e3fbecc44af4cbc85ddf1c12accefc9.api.mockbin.io/ #Server2
policy.rego
package example.authz
import future.keywords.if
default allow := false
allow if {
input.method == "GET"
}
最初と同様に起動します。
C:optaileron>aileron-windows-amd64 -f config.yml
{"time":"2025-04-14 00:24:16","level":"INFO","msg":"server started. listening on [::]:8080","datetime":{"date":"2025-04-14","time":"00:24:16.245","zone":"Local"},"location":{"file":"httpserver/server.go","func":"httpserver.(*runner).Run","line":56}}
curlで動作確認すると、POSTメソッドだと拒否、GETメソッドだと2つのMockbinにロードバランスされてますね!良い感じです。
C:optaileron>curl -X POST http://localhost:8080/get
{"status":403,"statusText":"Forbidden"}
C:optaileron>
C:optaileron>curl -X GET http://localhost:8080/get
{
"message": "Server1, Hello!"
}
C:optaileron>
C:optaileron>curl -X GET http://localhost:8080/get
{
"message": "Server2, Hello!"
}
C:optaileron>
C:optaileron>curl -X GET http://localhost:8080/get
{
"message": "Server1, Hello!"
}
C:optaileron>
プラガブルに自分の欲しい処理を書いていく感じが面白いな感じました。
独自の処理もMiddlewareとして追加できそうなので、対応できる範囲も広そうです。(業務ロジックやら何でもかんでもAILERONに実装してしまうとカオスになりそうなので、そこは注意かなと思いますが)
https://aileron-gateway.github.io/docs/how-it-works/
まだ他にも様々なモジュールが用意されているので、次は別のモジュールを試してみます。