-
Notifications
You must be signed in to change notification settings - Fork 4
/
27.txt
247 lines (183 loc) · 15.3 KB
/
27.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
[46] [DFN[プロキシ]]は、[[アプリケーション層プロトコル]]を中継するものです。
[[Web]] では、 [[HTTP]] や [[FTP]] などの通信を[[ネットワーク]]境界を超えさせるために使ったり、
[[キャッシュ]]や[[アプリケーション層]]の[[経路制御]]などの機能のために用いたりします。
* 仕様書
[REFS[
- [7] '''[CITE@en[RFC 7230 - Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing]] ([TIME[2014-06-07 01:59:35 +09:00]] 版) <https://tools.ietf.org/html/rfc7230#page-10>'''
- [16] [CITE@en[RFC 4918 - HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)]] ([TIME[2014-09-21 17:04:59 +09:00]] 版) <http://tools.ietf.org/html/rfc4918#section-18>
]REFS]
* プロキシの種類
[15] [[串]]は、[[キャッシュ]]、[[変形]]、[[経路制御]]、[[防火壁]]、[[ウイルス検査]]、
[[検閲]]など様々な目的のために利用されています。
[10] [[プロキシ]]は、用途や[[プロトコル]]、配置などによって、様々に分類されています。
[FIG(short list)[
- [[キャッシュ串]]
- [[共有串]]
- [[open proxy]]
- [[変形串]]
- [[順プロキシ]]
- [[逆プロキシ]]
- [[透過串]]
- [[interception proxy]]
]FIG]
[19] 特定の [[Webサイト]]の [[HTML]]
を書き換えたり [[JavaScript]] を注入したり、[[キャッシュ]]機能を強化したりして[[利用者]]側で高度な
[[Webサイト]]のカスタマイズを行うことを目的とした[[串]]もあります。
他の言語や方言に翻訳する[[串]]もあります。しかしこうした内容を書き換える[[串]]は[[利用者エージェント]]にとって
[[MITM]] 攻撃と区別がつかないので、好ましくないのかもしれません。
そのような書き換えがあったかどうか[[利用者エージェント]]側から確実に判定する方法はありません。
[31] 組織内ネットワークの出入口に当たる[[串]]や、年少者向けの[[フィルタリング]]を行う[[串]]など、
[[検閲]]を目的とした[[串]]は[[ドメイン名]]、[[IPアドレス]]、[[URL]]、[[応答]]の内容その他の[[要求]]や[[応答]]の特徴に基づき[[要求]]を遮断したり、
[[応答]]を改変・差し替えたりすることがあります。その場合は [CODE(HTTP)[[[403]]]]
などの[[状態符号]]が使われると思われますが、その保証はありません。また[[利用者エージェント]]側から通常の[[応答]]と確実に区別する方法はありません。
;; [32] [[透過プロキシ]]により、こうした改変が[[利用者]]の気づかないうちに行われている場合もあります。
[14] [[串]]は多段化できます。すなわち、[[串]]もまた[[串]]を使うことができます。
[EG[
[13] [[インターネット]]と[[アプリケーションサーバー]]の間に、
[[ネットワーク]]境界を超えると共に[[経路制御]]を行うための[[逆プロキシ]]と、
[[HTTPキャッシュ]]機能を持った[[プロキシ]]の2段階の[[サーバー]]を挟むことがあります。
]EG]
[11] あるいは、上位層の[[プロトコル]]の[[プロキシ]]を使った通信が、それとは別個に、
下位層の[[プロキシ]]を使った通信の上で行われることもあります。
[33] [[串]]は、その機能の一部または全部の利用に[[ログイン]]等の操作が必要なことがあります。
[[プロキシ]]の[[プロトコル]]に[[認証]]機能が組み込まれていることもあります。
[[ログイン]]等の操作を促す手段として [[captive portal]] が用いられる場合もあります。
[48] [[プロキシ]]の実現を目的とした[[プロトコル]]に次のようなものがあります。
[FIG(short list)[
- [[SOCKS]]
- [[PAC]]
- [[WPAD]]
]FIG]
[49] [[プロキシ]]を想定した機能を持った[[プロトコル]]に次のようなものがあります。
[FIG(short list)[
- [[HTTP]]
]FIG]
* HTTP 順プロキシ
[47] [[HTTP]] の[[仕様書]]における用語「[RUBYB[プロキシ]@en[proxy]]」は、
一般の技術用語としての[[プロキシ]]の一種で、
[[逆プロキシ]]と区別したい時は[DFN[[RUBYB[順プロキシ]@en[forward proxy]]]]といいます。
[1] [[クライアント]]によって選択されたメッセージ転送エージェントで、
何らかの[[絶対URL]]の[[要求]]を受け取り、
[[HTTP]] のインターフェイスを通じて翻訳することによりその要求を満足しようとするものを、
[[プロキシ]]といいます [SRC[>>7]]。
[8] [CODE(URI)@en[[[http:]]]] [[URL]] の[[要求]]の場合のように翻訳が最低限で済むこともあれば、
まったく異なる[[プロトコル]]のこともあります [SRC[>>7]]。
;; [36] [[HTTP]] の用語としての[[プロキシ]]は、一般用語 (あるいは [[HTTP]]
以外の分野における用語) としての[[プロキシ]]より範囲が狭く、
広義の[[プロキシ]]のうち [[HTTP]] を使うもので、かつ[[逆プロキシ]]ではないものだけを指しています。
[FIG(sequence)[
:C:[[クライアント]]
:P:[[串]]
:S:[[鯖]]
:C -> P:[[要求]]
:P -> S:[[要求]]
:S -> P:[[応答]]
:P -> C:[[応答]]
]FIG]
* 串への対応
[18] [[Webブラウザー]]その他の [[HTTP]] [[利用者エージェント]]のほとんどは[[串]]
([[順串]]) に対応しています。組織内ネットワーク等で[[串]]を介さないと [[Web]]
にアクセスできない環境も少なからず存在しています。
[20] [[串]] ([[順串]]) の多くも、より[[上流]]の[[串]]の指定に対応しています。
[21] 各ソフトウェアの独自の設定ファイル・設定画面やコマンドラインオプションで指定することも多いですが、
[[環境変数]] [CODE[[[http_proxy]]]] で指定できることも多々あります。
[22] [[HTTP]] 以外の[[プロトコル]]についても、設定画面等や[[環境変数]]
[CODE[[[FTP_PROXY]]]] 等で指定できるのが一般的です。 [[HTTP]]
以外の[[プロトコル]]も、[[クライアント]]と[[串]]の間は [[HTTP]]
で通信する [[FTP over HTTP]] のような方式が使われることがよくあります。
;; [26] [[HTTP]]、[[HTTPS]]、[[FTP]]、[[Gopher]]、[[WAIS]] といった[[プロトコル]]にそれぞれ[[串]]を指定できるのが普通です。
ただし [[Gopher]] や [[WAIS]] に対応していない[[利用者エージェント]]も最近は多くなっています。
;; [27] その他に [[SOCKS串]]にも対応するのが一般的です。
[28] [[串]]の設定は、同じネットワーク ([[イントラネット]]) 内へのアクセスや指定した[[ドメイン名]]のパターンに一致するアクセスには適用しないといった除外指定ができる場合もあります。
[23] 多くのソフトウェアは、[[串]]を使うか否か、使う場合はどこにある[[串]]を使うかを
[[JavaScript]] により記述できる [[PAC]] ([[proxy.pac]]) の指定に対応しています。
ネットワーク管理者等が作成した [[PAC]] の [[URL]] を当該ソフトウェアの設定等で指定しておくことで、
[[利用者]]はどの[[串]]が使われるか (使われないか) 意識せずに接続できます。
本方式は組織内ネットワーク等でよく用いられています。
;; 当然ながら、 [[PAC]] の [[URL]] へは[[串]]を介さずに接続できる必要があります。
[29] [[WPAD]] は、[[DHCP]] や [[DNS]] によって [[PAC]] の [[URL]] を配布する[[プロトコル]]です。
[[WPAD]] を用いると[[利用者]]が手動で [[PAC]] の [[URL]] を指定する必要すらなくなります。
;; [30] [[Webブラウザー]]以外の[[クライアント]]は [[PAC]] や [[WPAD]]
に対応していない場合も少なくありません。
[24] こうした[[串]]の設定は、ソフトウェアが独自に保持する場合もありますが、 [[OS]]
が提供する場合もあります。
[EG[
[25] [[Windows]] 上の [[IE]] と [[Chrome]] は、 [[Windows]] が提供する[[串]]の設定を利用しています。
]EG]
[35] [[WebSocket]] の取り扱いは、[[WebSocket接続の確立]]を参照。
[17] [[WebDAV]] に対応する[[串]]は、 [[HTTP/1.1]] に適合しなければ[['''なりません''']]
[SRC[>>16]]。
* 歴史
[FIG(quote)[
[FIGCAPTION[
[4] [[HTTP]] ([[RFC 1945]] 1.2, [[RFC 2068]] 1.3, [[RFC 2616]] 1.3)
]FIGCAPTION]
>
:proxy:An intermediary program which acts as both a server and a client
for the purpose of making requests on behalf of other clients.
Requests are serviced internally or by passing them [INS[[INS[{2068,2616}]] on]], with
possible translation, [DEL[on]]
to other servers. [DEL[A proxy must interpret and, if necessary, rewrite a request message before forwarding it. Proxies are often used as client-side portals through network firewalls and as helper applications for handling requests via protocols not implemented by the user agent.]] [INS[[INS[{2068,2616}]] A proxy [DEL[must]] [INS[MUST]] implement both the client and server requirements of this specification.]] [INS[[INS[{2616}]] A "transparent proxy" is a proxy that does not modify the request or response beyond what is required for proxy authentication and identification. A "non-transparent proxy" is a proxy that modifies the request or response in order to provide some added service to the user agent, such as group annotation services, media type transformation, protocol reduction, or anonymity filtering. Except where either transparent or non-transparent behavior is explicitly stated, the HTTP proxy requirements apply to both types of proxies.]]
:串:他の[[クライアント]]のために[[要求]]を行う目的で、[[サーバー]]とクライアントの両方として動作する中間プログラム。要求は内部的に service するか、又は必要なら翻訳した上で他のサーバーに渡します。 [DEL[串は、要求メッセージを転送する前に解釈し、必要なら書き換えなければなりません。串は、しばしばネットワーク防火壁のクライアント側玄関として使われたり、[[利用者エージェント]]が実装していないプロトコルを介した要求を扱う[[補助応用]]として使われたりします。]] [INS[串は、この仕様書のクライアント要件とサーバー要件の両方を実装しなければ'''なりません'''。]] [INS[[DFN[[[透過串]]]]は、串認証・識別に必要な分以上には要求や応答を編集しない串です。[DFN[[[非透過串]]]]は、利用者エージェントに[[集団注釈サービス]]、[[媒体型]]変換、プロトコル変更や匿名性濾過などの追加のサービスを提供するために要求や応答を修正する串です。透過か非透過かの動作が陽に言明されているところを除いて、 HTTP 串の要件は両方の型の串に適用します。]]
]FIG]
[6]
[CITE@en[RFC 3143 - Known HTTP Proxy/Caching Problems]] ([TIME[2008-08-30 12:43:01 +09:00]] 版) <http://tools.ietf.org/html/rfc3143>
* 関連
[9] [[interception proxy]] や[[透過串]]は、[[クライアント]]によって選択されたものではありませんから、
[[HTTP]] の定義による[[串]]ではありません [SRC[>>7 2.3.]]。
[12] [[串]]は[[上流]]に対しては[[クライアント]]、[[下流]]に対しては[[鯖]]として機能します。
* メモ
[2] もともと[CODE[串]]というのは「プロクシ」の後半の音から取った[[俗語]]だけど、語呂がいいのですっかり定着してしまった。
[3] 派生語: [[串刺し]], [[串規制]]
[5]
[CITE[国内open proxyの現状]] <http://spam.h1r.org/jpproxy/index.html>
([[名無しさん]] [WEAK[2006-05-27 02:42:05 +00:00]])
[34] [CITE@en[draft-rpeon-httpbis-exproxy-00 - Explicit Proxies for HTTP/2.0]]
([TIME[2015-04-24 04:17:39 +09:00]] 版)
<http://tools.ietf.org/html/draft-rpeon-httpbis-exproxy-00>
[37] [CITE[Pretty-Bad-Proxy: An Overlooked Adversary in Browsers’ HTTPS Deployments - Microsoft Research]]
([TIME[2015-09-13 00:16:48 +09:00]] 版)
<http://research.microsoft.com/apps/pubs/default.aspx?id=79323>
[38] [CITE@en[713023 – Websockets: don't prefer SOCKS to HTTP proxy until bug 449251 is fixed]]
([TIME[2015-09-14 23:36:09 +09:00]] 版)
<https://bugzilla.mozilla.org/show_bug.cgi?id=713023>
[39] [CITE@en[''''''[''''''chrome'''''']'''''' Index of /trunk/src/net/proxy]]
([TIME[2015-09-22 18:15:37 +09:00]] 版)
<http://src.chromium.org/viewvc/chrome/trunk/src/net/proxy/>
[40] [CITE[Secure Web Proxy - The Chromium Projects]]
([TIME[2016-04-23 03:43:10 +09:00]] 版)
<https://www.chromium.org/developers/design-documents/secure-web-proxy>
[41] [CITE[Data Saver - Google Chrome]]
([TIME[2016-04-23 17:44:55 +09:00]] 版)
<https://developer.chrome.com/multidevice/data-compression>
[42] [CITE@en[378637 – Add support for connecting to HTTP proxy over HTTPS]]
([TIME[2016-04-23 18:34:40 +09:00]] 版)
<https://bugzilla.mozilla.org/show_bug.cgi?id=378637>
[43] [CITE@en[Features/HTTPS - Squid Web Proxy Wiki]]
( ([TIME[2016-05-07 01:33:40 +09:00]]))
<http://wiki.squid-cache.org/Features/HTTPS>
[FIG(quote)[
[FIGCAPTION[
[44] [CITE[cURL - How To Use]]
( ([TIME[2016-05-31 06:05:05 +09:00]]))
<https://curl.haxx.se/docs/manpage.html#--proxy10>
]FIGCAPTION]
> --proxy1.0 <proxyhost'''[''':port''']'''>
> Use the specified HTTP 1.0 proxy. If the port number is not specified, it is assumed at port 1080.
> The only difference between this and the HTTP proxy option (-x, --proxy), is that attempts to use CONNECT through the proxy will specify an HTTP 1.0 protocol instead of the default HTTP 1.1.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[45] [CITE[cURL - How To Use]]
( ([TIME[2016-05-31 06:05:05 +09:00]]))
<https://curl.haxx.se/docs/manpage.html#-x>
]FIGCAPTION]
> -x, --proxy <'''['''protocol://''']''''''['''user:password@''']'''proxyhost'''[''':port''']'''>
> Use the specified proxy.
> The proxy string can be specified with a protocol:// prefix to specify alternative proxy protocols. Use socks4://, socks4a://, socks5:// or socks5h:// to request the specific SOCKS version to be used. No protocol specified, http:// and all others will be treated as HTTP proxies. (The protocol support was added in curl 7.21.7)
> If the port number is not specified in the proxy string, it is assumed to be 1080.
> This option overrides existing environment variables that set the proxy to use. If there's an environment variable setting a proxy, you can set proxy to "" to override it.
> All operations that are performed over an HTTP proxy will transparently be converted to HTTP. It means that certain protocol specific operations might not be available. This is not the case if you can tunnel through the proxy, as one with the -p, --proxytunnel option.
> User and password that might be provided in the proxy string are URL decoded by curl. This allows you to pass in special characters such as @ by using %40 or pass in a colon with %3a.
> The proxy host can be specified the exact same way as the proxy environment variables, including the protocol prefix (http://) and the embedded user + password.
]FIG]