nodex
nodex copied to clipboard
feat: add proxy config
Why
A proxy may be present when sending outbound requests. However, this PR was created because requests are not currently sent through a proxy.
What
- added the environment variable
NODEX_PROXY_ENDPOINT
- defined
ProxyConfig
- added the use of ProxyConfig in HubClient and HttpClient.
- added function "build_client" in HubClient and HttpClient to generate Client using the value of proxy.
Check
I built a proxy (nginx) in my local environment and verified that I can send requests via proxy.
The following are the logs recorded by the proxy.
(I have temporarily set NodeX
to the user_agent of reqwest to make the logs easier to read.)
$ tail logs/access.log
127.0.0.1 - - [14/Jan/2024:19:23:19 +0900] "POST http://localhost:8000/v1/device HTTP/1.1" 200 2 "-" "NodeX" "-"
127.0.0.1 - - [14/Jan/2024:19:23:22 +0900] "POST http://localhost:8000/v1/device-info HTTP/1.1" 200 2 "-" "NodeX" "-"
127.0.0.1 - - [14/Jan/2024:19:23:23 +0900] "POST http://localhost:8000/v1/heartbeat HTTP/1.1" 200 2 "-" "NodeX" "-"
127.0.0.1 - - [14/Jan/2024:19:23:24 +0900] "POST http://localhost:8000/v1/message/list HTTP/1.1" 200 4064 "-" "NodeX " "-"
127.0.0.1 - - [14/Jan/2024:19:23:28 +0900] "POST http://localhost:8000/v1/message/list HTTP/1.1" 200 4064 "-" "NodeX " "-"
127.0.0.1 - - [14/Jan/2024:19:23:33 +0900] "POST http://localhost:8000/v1/message/list HTTP/1.1" 200 4064 "-" "NodeX " "-"
127.0.0.1 - - [14/Jan/2024:19:23:39 +0900] "POST http://localhost:8000/v1/message/list HTTP/1.1" 200 4064 "-" "NodeX " "-"
127.0.0.1 - - [14/Jan/2024:19:23:43 +0900] "POST http://localhost:8000/v1/message/list HTTP/1.1" 200 4064 "-" "NodeX " "-"