kingluo commented on issue #7844: URL: https://github.com/apache/apisix/issues/7844#issuecomment-1238888074
@nareshnagamalle apisix doesn't support sending the request to upstream via external proxy server yet. What's your type of proxy server? socks5? If so, you could make a trick with iptables and tcpsocks to achieve your goal. Example: ```bash # Here I use ssh to create a socks5 server as demo # in your case, you should use your real proxy instead ssh -o ServerAliveInterval=60 -N -D 127.0.0.1:30000 <username>@<ssh server> -p 20022 & # compile and run tcpsocks cd /opt git clone https://github.com/vi/tcpsocks cd tcpsocks make ./tcpsocks 0.0.0.0 12345 REDIRECT REDIRECT 127.0.0.1 30000 # in another terminal # setup iptables rules iptables -t nat -A QQQ -p tcp -d 54.147.68.244 -j REDIRECT --to-ports 12345 iptables -t nat -I OUTPUT 1 -j QQQ iptables -t nat -I PREROUTING 1 -j QQQ # setup a rule in apisix curl http://127.0.0.1:9080/apisix/admin/routes/route_via_proxy -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri": "/anything", "upstream": { "type": "roundrobin", "nodes": { "54.147.68.244": 1 } } }' # check if it works curl -i http://127.0.0.1:9080/anything HTTP/1.1 200 OK Content-Type: application/json Content-Length: 386 Connection: keep-alive Date: Wed, 07 Sep 2022 04:06:54 GMT Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Server: APISIX/2.15.0 ... # check tcpsocks logs xxx:55646 -> 54.147.68.244:80 [5->6] 54.147.68.244:80 -> xxx:55646 [6->5] Started 54.147.68.244:80 -> xxx:55646 [6->5] 616:214 Finished ``` Noe that `54.147.68.244` is one of the resolved ip address of `httpbin.org`. So the shortage of this way is you could only use ip address to access your upstream. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
