-
Notifications
You must be signed in to change notification settings - Fork 4
/
20.txt
297 lines (224 loc) · 14.5 KB
/
20.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
[1] [DFN[[CODE@en[[[http_proxy]]]]]] は、 [CODE(URI)@en[[[http:]]]] [[URL]]
の処理に使われるべき[[串]]を指定する[[環境変数]]です。
* 変数名
[13] 他の多くの[[環境変数]]がすべて[[大文字]]で綴られるのに対し、
[CODE@en[[[http_proxy]]]] が[[小文字]]なのは、
[[CGI]] [[環境変数]] [CODE(CGI)@en[[[HTTP_PROXY]]]] との混同を避けるためです。
[14] [[HTTP]] に [CODE(HTTP)@en[Proxy:]] [[ヘッダー]]は (現時点では) 存在しないので通常の[[要求]]の処理ではそのような[[環境変数]]が設定されることはありませんが、
悪意ある[[クライアント]]が [CODE(HTTP)@en[Proxy:]] [[ヘッダー]]を指定することで任意の[[串]]の[[ホスト]]を指定できてしまうと[[セキュリティー]]上の問題となります。
(大文字の[[環境変数]]が設定された状態で大文字の[[環境変数]]を参照する[[ライブラリー]]の類を呼び出したり、
大文字の[[環境変数]]を参照する外部の[[プログラム]]を起動したりすると、
その動作が影響を受けることになります。)
[15] 中には現在でもこのような状況を想定せずに [CODE@en[[[HTTP_PROXY]]]]
を使う[[プログラム]]や、大文字と小文字の両方を使う[[プログラム]]が存在しているようです。
[16] [[HTTP鯖]]や[[アプリケーション鯖]]、あるいは [[Webアプリケーション]]の実装は、
そのような[[ライブラリー]]や[[プログラム]]を呼び出すことが無いように注意しなければなりません。
;; [17] [[CGI]] を使うことが少なくなった現在でも、 [[HTTP鯖]]の内部的な利用や
[[CGI]] とある程度の互換性を持った[[Webアプリケーション]]動作環境等が [[CGI]]
と同等の[[環境変数]]を設定することがあります。
* 値
[12] 値が設定される場合、[[ホスト]] ([[ホスト名]]と [CODE[[[:]]]] と[[ポート]]を連結した文字列)
となることが期待されているようです。
* URL scheme
[30] [[curl]] は先頭が [CODE[http://]] や [CODE[https://]] でなければ、
[[URL scheme]] の省略とみなすようです。それ以外だと [CODE[:]] が含まれていても
[[userinfo]] の一部とみなしたりします。
[32] [[curl]] は [CODE[http_proxy]] で [CODE[https://]] を指定しても
[[素のHTTP]]で接続するようです。 [TIME[2016-06-03T00:57:45.100Z]]
[33] [[wget]] は [CODE[:]] 以外 + [CODE[://]] で始まると [[URL]]
とみなし、 [CODE[:]] 以外 + [CODE[:]] + [CODE[//]] 以外で始まると [[Unix]]
風 [[FTP]] の指定 ([CODE[:]] の前までがホスト名) とみなすようです。
[CODE[http:hoge]] は [CODE[ftp://hoge/]] になります。
[TIME[2016-06-03T01:01:49.300Z]]
[2] 古い [[LWP]] は [CODE@en[localhost:12345]] のように [[scheme]] が明示されていないと
[CODE(URI)@en[localhost:]] を [[URL scheme]] とみなしてしまいます。 [CODE(URI)@en[http://localhost:12345]]
のようにすれば回避できます。
[REFS[
- [3] [CITE[環境変数 HTTP_PROXY の値には "http://" を含むのか含まないのか - Haskell はスケるよ]]
([TIME[2012-11-02 04:42:37 +09:00]] 版)
<http://d.hatena.ne.jp/takatoh/20070522/http_proxy>
]REFS]
* userinfo
[34] [[URL scheme]] が省略された場合も含め、[[userinfo]]
で[[プロキシ認証]]の[[利用者名]]と[[合言葉]]を指定できます。
* ポート
[31] [[wget]] は [N[80]]、 [[curl]] は [N[1080]] を[[既定のポート番号]]とするようです。
* [CODE[no_proxy]]
[35] [[wget]] も [[curl]] も、 [CODE[no_proxy]] での指定は、 [[URL]]
の[F[ホスト]]との比較になります。 [[URL]] の[F[ホスト]]を[[名前解決]]したら
[CODE[no_proxy]] に指定された[[IPアドレス]]に一致するとしても、
[[プロキシ]]を使わない理由にはしません。
* 実装
[4] [CITE@en[Proxies - GNU Wget 1.13.4 Manual]]
( ([TIME[2012-11-02 04:43:40 +09:00]] 版))
<http://www.gnu.org/software/wget/manual/html_node/Proxies.html>
[5] [CITE[cURL - How To Use]]
( ([TIME[2012-08-28 08:45:05 +09:00]] 版))
<http://curl.haxx.se/docs/manpage.html>
[6] [CITE[Help on Environment variables]]
( ([TIME[2004-05-23 22:59:56 +09:00]] 版))
<http://lynx.isc.org/lynx2.8.6/lynx2-8-6/lynx_help/keystrokes/environments.html>
[7] [CITE[66057 – Proxy: $http_proxy should influence proxy settings]]
( ([TIME[2012-11-02 04:46:17 +09:00]] 版))
<https://bugzilla.mozilla.org/show_bug.cgi?id=66057>
[8] [CITE[LWP::UserAgent - search.cpan.org]]
( ([TIME[2012-11-02 04:47:01 +09:00]] 版))
<http://search.cpan.org/dist/libwww-perl/lib/LWP/UserAgent.pm#Proxy_attributes>
[9] [CITE[Libwww Proxies and Gateways Setup]]
( ([TIME[1998-08-06 01:47:09 +09:00]] 版))
<http://www.w3.org/Library/User/Using/Proxy.html>
[10] [CITE@en[CLI Usage | Heroku Dev Center]]
( ([TIME[2014-10-10 04:30:21 +09:00]] 版))
<https://devcenter.heroku.com/articles/using-the-cli>
[11] [CITE[Sauce Connect · Sauce Labs Docs]]
( ([TIME[2014-10-21 18:46:44 +09:00]] 版))
<https://docs.saucelabs.com/reference/sauce-connect/>
[FIG(quote)[
[FIGCAPTION[
[18] [CITE@en[ssllabs/ssllabs-scan: A command-line reference-implementation client for SSL Labs APIs, designed for automated and/or bulk testing.]]
( ([TIME[2016-05-09 19:26:38 +09:00]]))
<https://github.com/ssllabs/ssllabs-scan/>
]FIGCAPTION]
> The rules of Go's ProxyFromEnvironment apply (HTTP_PROXY, HTTPS_PROXY, NO_PROXY, lowercase variants allowed).
]FIG]
[FIG(quote)[
[FIGCAPTION[
[19] [CITE@en[GNU Wget 1.17.1 Manual: Proxies]]
( ([TIME[2016-06-01 00:34:48 +09:00]]))
<http://www.gnu.org/software/wget/manual/html_node/Proxies.html>
]FIGCAPTION]
> following environment variables:
> http_proxy
> https_proxy
> If set, the http_proxy and https_proxy variables should contain the URLs of the proxies for HTTP and HTTPS connections respectively.
> ftp_proxy
> This variable should contain the URL of the proxy for FTP connections. It is quite common that http_proxy and ftp_proxy are set to the same URL.
> no_proxy
> This variable should contain a comma-separated list of domain extensions proxy should not be used for. For instance, if the value of no_proxy is ‘.mit.edu’, proxy will not be used to retrieve documents from MIT.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[20] [CITE@en[GNU Wget 1.17.1 Manual: Proxies]]
( ([TIME[2016-06-01 00:35:33 +09:00]]))
<http://www.gnu.org/software/wget/manual/html_node/Proxies.html>
]FIGCAPTION]
> Some proxy servers require authorization to enable you to use them. The authorization consists of username and password, which must be sent by Wget. As with HTTP authorization, several authentication schemes exist. For proxy authorization only the Basic authentication scheme is currently implemented.
> You may specify your username and password either through the proxy URL or through the command-line options. Assuming that the company’s proxy is located at ‘proxy.company.com’ at port 8001, a proxy URL location containing authorization data might look like this:
> http://hniksic:mypassword@proxy.company.com:8001/
> Alternatively, you may use the ‘proxy-user’ and ‘proxy-password’ options, and the equivalent .wgetrc settings proxy_user and proxy_password to set the proxy username and password.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[21] [CITE[cURL - How To Use]]
( ([TIME[2016-05-31 06:05:05 +09:00]]))
<https://curl.haxx.se/docs/manpage.html#--noproxy>
]FIGCAPTION]
> --noproxy <no-proxy-list>
> Comma-separated list of hosts which do not use a proxy, if one is specified. The only wildcard is a single * character, which matches all hosts, and effectively disables the proxy. Each name in this list is matched as either a domain which contains the hostname, or the hostname itself. For example, local.com would match local.com, local.com:80, and www.local.com, but not www.notlocal.com. (Added in 7.19.4).
]FIG]
[FIG(quote)[
[FIGCAPTION[
[22] [CITE[cURL - How To Use]]
( ([TIME[2016-05-31 06:05:05 +09:00]]))
<https://curl.haxx.se/docs/manpage.html#ENVIRONMENT>
]FIGCAPTION]
> The environment variables can be specified in lower case or upper case. The lower case version has precedence. http_proxy is an exception as it is only available in lower case.
> Using an environment variable to set the proxy has the same effect as using the --proxy option.
> http_proxy '''['''protocol://''']'''<host>'''[''':port''']'''
> Sets the proxy server to use for HTTP.
> HTTPS_PROXY '''['''protocol://''']'''<host>'''[''':port''']'''
> Sets the proxy server to use for HTTPS.
> '''['''url-protocol''']'''_PROXY '''['''protocol://''']'''<host>'''[''':port''']'''
> Sets the proxy server to use for '''['''url-protocol''']''', where the protocol is a protocol that curl supports and as specified in a URL. FTP, FTPS, POP3, IMAP, SMTP, LDAP etc.
> ALL_PROXY '''['''protocol://''']'''<host>'''[''':port''']'''
> Sets the proxy server to use if no protocol-specific proxy is set.
> NO_PROXY <comma-separated list of hosts>
> list of host names that shouldn't go through any proxy. If set to a asterisk '*' only, it matches all hosts.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[23] [CITE[W3M FAQ]]
( ([TIME[2001-02-01 18:02:39 +09:00]]))
<http://homepage2.nifty.com/aito/w3m/FAQ.html>
]FIGCAPTION]
> 環境変数 HTTP_proxy を設定するか,"o" コマンドのオプション設定パネル で設定します.例えば proxy.hogege.com というホストの 8000番ポートを 利用する場合,
> http://proxy.hogege.com:8000/
> と設定します.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[24] [CITE[LWP::UserAgent - search.cpan.org]]
( ([TIME[2016-06-01 01:04:32 +09:00]]))
<http://search.cpan.org/dist/libwww-perl/lib/LWP/UserAgent.pm#Proxy_attributes>
]FIGCAPTION]
> Load proxy settings from *_proxy environment variables. You might specify proxies like this (sh-syntax):
> gopher_proxy=http://proxy.my.place/
> wais_proxy=http://proxy.my.place/
> no_proxy="localhost,example.com"
> export gopher_proxy wais_proxy no_proxy
> csh or tcsh users should use the setenv command to define these environment variables.
> On systems with case insensitive environment variables there exists a name clash between the CGI environment variables and the HTTP_PROXY environment variable normally picked up by env_proxy(). Because of this HTTP_PROXY is not honored for CGI scripts. The CGI_HTTP_PROXY environment variable can be used instead.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[25] [CITE@ja[プロキシ下でLinuxを使う際のメモ - Λlisue's blog]]
( ([TIME[2016-06-01 01:07:06 +09:00]]))
<http://lambdalisue.hatenablog.com/entry/2013/06/25/140630>
]FIGCAPTION]
> # 認証が必要なプロキシの場合
> PROXY="$USERNAME:$PASSWORD@$HOST:$PORT"
> # 認証が不要なプロキシの場合
> PROXY="$HOST:$PORT"
> # 実際の環境変数の設定
> export http_proxy="http://$PROXY"
> export https_proxy="https://$PROXY"
> export ftp_proxy="ftp://$PROXY"
> # 大文字バージョンしか認識しないプログラム用
> export HTTP_PROXY="http://$PROXY"
> export HTTPS_PROXY="https://$PROXY"
> export FTP_PROXY="ftp://$PROXY"
> # プロキシを利用しないアドレスの指定(必須)
> export no_proxy="127.0.0.1,localhost"
> export NO_PROXY="$no_proxy"
]FIG]
[FIG(quote)[
[FIGCAPTION[
[26] [CITE[いつか見た惑星: プロキシ環境下でgitを使う]]
( ([TIME[2016-04-27 04:13:21 +09:00]]))
<http://sushichop.blogspot.jp/2013/09/git.html>
]FIGCAPTION]
> 認証付きプロキシサーバの場合は認証ID、PW込みでプロキシ指定する。また、認証ID、PW、プロキシサーバURLにURIとして使用できない文字(@等)が含まれる場合はURLエンコードすること。
> 書式
> $ git config --global http.proxy http://認証ID:認証PW@プロキシサーバのURL:ポート番号
> $ git config --global https.proxy http://認証ID:認証PW@プロキシサーバのURL:ポート番号
> 設定例(認証IDがfoo.bar@example.com、認証PWがhogepassの場合)
> $ git config --global http.proxy http://foo.bar%40example.com:hogepass@proxy.example.com:8080
> $ git config --global https.proxy http://foo.bar%40example.com:hogepass@proxy.example.com:8080
]FIG]
[FIG(quote)[
[FIGCAPTION[
[27] [CITE@ja[no_proxy にネットワークアドレスとかワイルドカードを指定しても期待通りに動かない、でどうするかというお話 - 双六工場日誌]]
( ([TIME[2016-06-01 01:09:42 +09:00]]))
<http://sechiro.hatenablog.com/entry/2013/08/06/no_proxy_%E3%81%AB%E3%83%8D%E3%83%83%E3%83%88%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%A2%E3%83%89%E3%83%AC%E3%82%B9%E3%81%A8%E3%81%8B%E3%83%AF%E3%82%A4%E3%83%AB%E3%83%89%E3%82%AB%E3%83%BC%E3%83%89%E3%82%92>
]FIGCAPTION]
> ただ、この際の「no_proxy」の仕様が曲者で、僕が確認したプログラムではここに設定できるのは「IPアドレス」もしくは「ドメイン名」のみとなっており、プロキシを経由したくないIPアドレスを複数指定する場合は、IPアドレスをひたすらカンマ区切りで列挙する必要があります。たとえば、内部サーバへの接続の際にIPアドレスをそのまま使っている場合、プロキシ経由してほしくないIPアドレスのすべてをここに書き下すことになります。 たとえば"192.168.0.0/24"とか"172.16.0.*"といった、ネットワークアドレスでの指定やワイルドカードでの指定は期待通りの動作になりません。
]FIG]
[28] [CITE@en[821655 – System proxy settings via $http_proxy/$HTTP_PROXY are not recognized anymore]]
( ([TIME[2016-06-01 01:10:52 +09:00]]))
<https://bugzilla.mozilla.org/show_bug.cgi?id=821655>
[FIG(quote)[
[FIGCAPTION[
[29] [CITE[lftp.1]]
( ([TIME[2016-05-19 18:00:12 +09:00]]))
<http://lftp.yar.ru/lftp-man.html>
]FIGCAPTION]
>
> ftp:proxy (URL)
> specifies FTP proxy to use. To disable proxy set this to empty string. Note that it
> is a FTP proxy which uses FTP protocol, not FTP over HTTP. Default value is taken from
> environment variable ftp_proxy if it starts with ``ftp://''. If your FTP proxy
> requires authentication, specify user name and password in the URL. If ftp:proxy
> starts with http:// then hftp protocol (FTP over HTTP proxy) is used instead of FTP
> automatically.
>
]FIG]