Demo: HTTP over VSOCK (Hyper-V sockets)
Getting Started
Getting Started with AWS Nitro Enclaves
-
Clone this repository.
$ git clone https://github.com/koron/http-over-vsock.git
-
Start a server in Enclave
$ cd http-over-vsock $ make enclave-run
-
Build a client and make requests.
Build a client
$ cd http-over-vsock/client $ go build
Run it to make a HTTP request over vsock.
$ ./clieht http://16:1234/ Hello VSOCK (/)
The response will be changed when you change path of request URL.
$ ./clieht http://16:1234/foo/bar Hello VSOCK (/foo/bar)
-
(OPTIONAL) Show server logs
Open another terminal and run this:
$ cd http-over-vsock $ make enclave-console
To terminate logs, interrupt with Ctrl-C or so.
See Makefile for details.
Getting Started with Windows and WSL2
- Host: Windows 10
- Guest: WSL2 Ubuntu-22.04
-
Run HTTP server on WSL2 Ubuntu (guest) which listen VSOCK
$ cd server $ go build $ sudo ./server
-
Detemine VMID (GUID)
> hcsdiag list C34EC814-C4A9-411C-BF5D-559529ECA7AB VM, Running, C34EC814-C4A9-411C-BF5D-559529ECA7AB, WSL
on system administrator console.
-
GET from host Windows via Hyper-V socket
> cd client > go build > .\client.exe http://C34EC814-C4A9-411C-BF5D-559529ECA7AB:1234
Multiple hosts forwarder on AWS
Enclave内から複数のホストへリクエストを転送するサンプルです。
このサンプルではEnclave内で複数のホスト名それぞれにループバックIPに割り当てて、 それぞれのホスト(=ループバックIP)に対してフォワーダーとvsock-proxyの組を起動し ています。これによりEnclave内から複数のホストへアクセスできます。
以下はサンプルをAWS Nitro Enclaveで実行するための手順です。
-
Start a server2 in Enclave
$ cd http-over-vsock $ make enclave2-run
-
Start vsock proxies on EC2
$ cd http-over-vsock/server2 $ ./run-vsock-proxies
-
Build a client
$ cd http-over-vsock/client $ go build
-
Make requests
Get local response.
$ cd http-over-vsock/client $ ./clieht http://16:1234/
Get remote (google)
$ cd http-over-vsock/client $ ./clieht http://16:1234/google
You can GET from Google, Amazon, Facebook, and Twitter.
- Google -
./clieht http://16:1234/google
- Amazon -
./clieht http://16:1234/amazon
- Facebook -
./clieht http://16:1234/facebook
- Twitter -
./clieht http://16:1234/twitter
- Google -
-
(OPTIONAL) Show server logs
Open another terminal and run this:
$ cd http-over-vsock $ make enclave2-console
To terminate logs, interrupt with Ctrl-C or so.
-
(OPTIONAL) Clean up
-
Stop vsock proxies which started at step 2.
$ killall vsock-proxy
-
Stop server2 in Enclave
$ cd http-over-vsock $ make enclave2-terminate
-