http_proxyの挙動確認
はじめに
localhostへの通信さえもプロキシサーバを通るように設定できると聞いたので、実験。
環境
- Ubuntu18.04
- bash
実験
proxy設定前
$ curl http://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
proxy設定後
proxy設定前
$ curl http://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
proxy設定後
1行目でproxyの設定をしている。
実際にはプロキシサーバを立ててないので localhost:9999
に繋げないが、プロキシサーバに繋ごうとしているのが分かる。
$ export http_proxy=localhost:9999
$ curl http://google.com
curl: (7) Failed to connect to localhost port 9999: Connection refused
proxyを通らないホストを指定
1行目でproxyを通らないホストを指定している。
プロキシサーバを通らずにhttpアクセスできた。
$ export no_proxy=google.com
$ curl http://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
おわりに
プロキシの設定について少し賢くなった。
Author And Source
この問題について(http_proxyの挙動確認), 我々は、より多くの情報をここで見つけました https://qiita.com/kabik/items/ae45613b8374b8064883著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .