终端命令行;
设置代理:
export http_proxy=http://172.16.2.16:3199
export https_proxy=http://172.16.2.16:3199
取消代理设置:
unset http_proxy
unset https_proxy
演示:
book@ubuntu:~/pt1416/02-hellogolang/grpcTest/client$ go run
2022/03/30 17:09:01 err where calling sayHello:rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing failed to do connect handshake, response: \"HTTP/1.1 403 Forbidden\\r\\nContent-Length: 333\\r\\nCache-Control: no-cache\\r\\nConnection: keep-alive\\r\\nContent-Type: text/html\\r\\nPragma: no-cache\\r\\n\\r\\n<!DOCTYPE html>\\n<html>\\n\\t<head> <title>COW Proxy</title> </head>\\n\\t<body>\\n\\t\\t<h1>[Error] Forbidden tunnel port</h1>\\n\\t\\t<p>HTTP Request <strong>CONNECT :9000</strong></p> <p>Please contact proxy admin.</p>\\n\\t\\t<hr />\\n\\t\\tGenerated by <i>COW 0.9.8</i> <br />\\n\\t\\tHost <i>it-cowproxy-master</i> <br />\\n\\t\\tWed Mar 30 17:09:01 2022\\n\\t</body>\\n</html>\\n\""
exit status 1
book@ubuntu:~/pt1416/02-hellogolang/grpcTest/client$ unset https_proxy
book@ubuntu:~/pt1416/02-hellogolang/grpcTest/client$ go run
2022/03/30 17:09:54 err where calling sayHello:rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing failed to do connect handshake, response: \"HTTP/1.1 403 Forbidden\\r\\nContent-Length: 333\\r\\nCache-Control: no-cache\\r\\nConnection: keep-alive\\r\\nContent-Type: text/html\\r\\nPragma: no-cache\\r\\n\\r\\n<!DOCTYPE html>\\n<html>\\n\\t<head> <title>COW Proxy</title> </head>\\n\\t<body>\\n\\t\\t<h1>[Error] Forbidden tunnel port</h1>\\n\\t\\t<p>HTTP Request <strong>CONNECT :9000</strong></p> <p>Please contact proxy admin.</p>\\n\\t\\t<hr />\\n\\t\\tGenerated by <i>COW 0.9.8</i> <br />\\n\\t\\tHost <i>it-cowproxy-master</i> <br />\\n\\t\\tWed Mar 30 17:09:54 2022\\n\\t</body>\\n</html>\\n\""
exit status 1
book@ubuntu:~/pt1416/02-hellogolang/grpcTest/client$ unset http_proxy
book@ubuntu:~/pt1416/02-hellogolang/grpcTest/client$ go run
2022/03/30 17:10:00 respond from Server :Hello from the server!
book@ubuntu:~/pt1416/02-hellogolang/grpcTest/client$