@@ -26,10 +26,95 @@ This service can be used to proxy [HTTPS outcalls](https://internetcomputer.org/
26
26
27
27
Run proxy:
28
28
``` bash
29
- docker run --name redis -d -p 6379:6379 redis:latest
29
+ # docker run --name redis -d -p 6379:6379 redis:latest # optional redis
30
30
cargo run -p idempotent-proxy-server
31
31
```
32
32
33
+ ### Building and running AWS Nitro Enclave image
34
+
35
+ #### Setup host machine
36
+
37
+ https://docs.marlin.org/learn/oyster/core-concepts/networking/outgoing
38
+
39
+ ``` bash
40
+ wget -O vsock-to-ip-transparent http://public.artifacts.marlin.pro/projects/enclaves/vsock-to-ip-transparent_v1.0.0_linux_amd64
41
+ chmod +x vsock-to-ip-transparent
42
+ ./vsock-to-ip-transparent --vsock-addr 3:1200
43
+ ```
44
+
45
+ https://docs.marlin.org/learn/oyster/core-concepts/networking/incoming
46
+
47
+ iptables rules:
48
+ ``` bash
49
+ # route incoming packets on port 80 to the transparent proxy
50
+ iptables -A PREROUTING -t nat -p tcp --dport 80 -i ens5 -j REDIRECT --to-port 1200
51
+ # route incoming packets on port 443 to the transparent proxy
52
+ iptables -A PREROUTING -t nat -p tcp --dport 443 -i ens5 -j REDIRECT --to-port 1200
53
+ # route incoming packets on port 1025:65535 to the transparent proxy
54
+ iptables -A PREROUTING -t nat -p tcp --dport 1025:65535 -i ens5 -j REDIRECT --to-port 1200
55
+ ```
56
+
57
+ ``` bash
58
+ wget -O port-to-vsock-transparent http://public.artifacts.marlin.pro/projects/enclaves/port-to-vsock-transparent_v1.0.0_linux_amd64
59
+ chmod +x port-to-vsock-transparent
60
+ ./port-to-vsock-transparent --vsock 88 --ip-addr 0.0.0.0:1200
61
+ ```
62
+
63
+ #### Build and run enclave
64
+
65
+ The following steps should be run in AWS Nitro-based instances.
66
+
67
+ https://docs.aws.amazon.com/enclaves/latest/user/getting-started.html
68
+
69
+ ``` bash
70
+ sudo nitro-cli build-enclave --docker-uri ghcr.io/ldclabs/idempotent-proxy_enclave_amd64:latest --output-file idempotent-proxy_enclave_amd64.eif
71
+ # Start building the Enclave Image...
72
+ # Using the locally available Docker image...
73
+ # Enclave Image successfully created.
74
+ # {
75
+ # "Measurements": {
76
+ # "HashAlgorithm": "Sha384 { ... }",
77
+ # "PCR0": "bbfe317cdaba604e1364fbd254150ce25516d83e31a87f8b3d8acb163286f57f51d8b3f6b2a482ac209b758334d996d9",
78
+ # "PCR1": "4b4d5b3661b3efc12920900c80e126e4ce783c522de6c02a2a5bf7af3a2b9327b86776f188e4be1c1c404a129dbda493",
79
+ # "PCR2": "9ea2080d6e6bd61f03a62357a1cbbae278b070db5df6b1fe5c57821ff249b77add0f95dab0a5beec7aa6ef6735f27b14"
80
+ # }
81
+ # }
82
+ sudo nitro-cli run-enclave --cpu-count 2 --memory 512 --enclave-cid 88 --eif-path idempotent-proxy_enclave_amd64.eif --debug-mode
83
+ # Started enclave with enclave-cid: 88, memory: 512 MiB, cpu-ids: [1, 3]
84
+ # {
85
+ # "EnclaveName": "idempotent-proxy_enclave_amd64",
86
+ # "EnclaveID": "i-056e1ab9a31cd77a0-enc190ca7263013fd3",
87
+ # "ProcessID": 21493,
88
+ # "EnclaveCID": 88,
89
+ # "NumberOfCPUs": 2,
90
+ # "CPUIDs": [
91
+ # 1,
92
+ # 3
93
+ # ],
94
+ # "MemoryMiB": 512
95
+ # }
96
+ sudo nitro-cli describe-enclaves
97
+ sudo nitro-cli console --enclave-id i-056e1ab9a31cd77a0-enc190ca7263013fd3
98
+ sudo nitro-cli terminate-enclave --enclave-id i-056e1ab9a31cd77a0-enc190ca7263013fd3
99
+ ```
100
+
101
+
102
+ #### Make a request
103
+
104
+ ``` bash
105
+ curl -v -X POST \
106
+ --url http://YOUR_HOST/ \
107
+ --header ' content-type: application/json' \
108
+ --header ' x-forwarded-host: cloudflare-eth.com' \
109
+ --header ' idempotency-key: key_001' \
110
+ --data ' {
111
+ "id": 1,
112
+ "jsonrpc": "2.0",
113
+ "method": "eth_getBlockByNumber",
114
+ "params": ["latest", false]
115
+ }'
116
+ ```
117
+
33
118
## License
34
119
Copyright © 2024 [ LDC Labs] ( https://github.com/ldclabs ) .
35
120
0 commit comments