Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4d1ca1

Browse files
committed
chore: add README
1 parent2bb9b3e commite4d1ca1

File tree

2 files changed

+50
-13
lines changed

2 files changed

+50
-13
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#AI Bridge Proxy
2+
3+
A MITM (Man-in-the-Middle) proxy server for intercepting and decrypting HTTPS requests to AI providers.
4+
5+
##Overview
6+
7+
The AI Bridge Proxy intercepts HTTPS traffic, decrypts it using a configured CA certificate, and forwards requests to AI Bridge for processing.
8+
9+
##Configuration
10+
11+
###Certificate Setup
12+
13+
Generate a CA key pair for MITM:
14+
15+
####1. Generate a new private key
16+
17+
```sh
18+
openssl genrsa -out mitm.key 2048
19+
chmod 400 mitm.key
20+
```
21+
22+
####2. Create a self-signed CA certificate
23+
24+
```sh
25+
openssl req -new -x509 -days 365 \
26+
-key mitm.key \
27+
-out mitm.crt \
28+
-subj"/CN=Coder AI Bridge Proxy CA"
29+
```
30+
31+
###Configuration options
32+
33+
| Environment Variable| Description| Default|
34+
|------------------------------------|----------------------------------|---------|
35+
|`CODER_AIBRIDGE_PROXY_ENABLED`| Enable the AI Bridge Proxy|`false`|
36+
|`CODER_AIBRIDGE_PROXY_LISTEN_ADDR`| Address the proxy listens on|`:8888`|
37+
|`CODER_AIBRIDGE_PROXY_CERT_FILE`| Path to the CA certificate file| -|
38+
|`CODER_AIBRIDGE_PROXY_KEY_FILE`| Path to the CA private key file| -|

‎enterprise/aibridgeproxyd/aibridgeproxyd.go‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
// It is responsible for:
1919
// - intercepting HTTPS requests to AI providers
2020
// - decrypting requests using the configured CA certificate
21-
// - forwarding requests toaibridge for processing
21+
// - forwarding requests toaibridged for processing
2222
typeServerstruct {
2323
logger slog.Logger
2424
proxy*goproxy.ProxyHttpServer
@@ -55,8 +55,7 @@ func New(ctx context.Context, logger slog.Logger, opts Options) (*Server, error)
5555

5656
// Decrypt all HTTPS requests via MITM. Requests are forwarded to
5757
// the original destination without modification for now.
58-
// TODO(ssncferreira): Route requests to aibridged
59-
// will be implemented upstack.
58+
// TODO(ssncferreira): Route requests to aibridged will be implemented upstack.
6059
// Related to https://github.com/coder/internal/issues/1181
6160
proxy.OnRequest().HandleConnect(goproxy.AlwaysMitm)
6261

@@ -82,6 +81,16 @@ func New(ctx context.Context, logger slog.Logger, opts Options) (*Server, error)
8281
returnsrv,nil
8382
}
8483

84+
// Close gracefully shuts down the proxy server.
85+
func (s*Server)Close()error {
86+
ifs.httpServer==nil {
87+
returnnil
88+
}
89+
ctx,cancel:=context.WithTimeout(context.Background(),5*time.Second)
90+
defercancel()
91+
returns.httpServer.Shutdown(ctx)
92+
}
93+
8594
// loadMitmCertificate loads the CA certificate and key for MITM into goproxy.
8695
funcloadMitmCertificate(certFile,keyFilestring)error {
8796
tlsCert,err:=tls.LoadX509KeyPair(certFile,keyFile)
@@ -102,13 +111,3 @@ func loadMitmCertificate(certFile, keyFile string) error {
102111

103112
returnnil
104113
}
105-
106-
// Close gracefully shuts down the proxy server.
107-
func (s*Server)Close()error {
108-
ifs.httpServer==nil {
109-
returnnil
110-
}
111-
ctx,cancel:=context.WithTimeout(context.Background(),5*time.Second)
112-
defercancel()
113-
returns.httpServer.Shutdown(ctx)
114-
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp