aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/http/headers/x-forwarded-for/index.html
blob: 546a4ed60c2259caadb92208989e31fa3ff01230 (plain)
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
---
title: X-Forwarded-For
slug: Web/HTTP/Headers/X-Forwarded-For
translation_of: Web/HTTP/Headers/X-Forwarded-For
---
<div>{{HTTPSidebar}}</div>

<p><strong><code>X-Forwarded-For</code></strong> (XFF) 標頭是辨識用戶端透過 HTTP 代理或負載平衡 IP 位置來源的,事實上的標準。如果流量是在伺服器與用戶端中間擷取,伺服器日誌就只會代理或負載平衡的 IP 位置。如果要檢查用戶端的 IP 的原始來源,就會去檢查 <code>X-Forwarded-For</code> 請求標頭。</p>

<p>這個標頭用於除錯、分析、產生與位置相關的內容、透過設計也洩漏部分隱私資訊,例如用戶端的 IP 位置。因此在部署此標頭時,必須考慮到用戶的隱私。</p>

<p>此 HTTP 標頭的標準化版本為 {{HTTPHeader("Forwarded")}} 標頭。</p>

<p><code>X-Forwarded-For</code> 也是個說明 email-message 是從哪個帳戶轉發的 email-header。</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">標頭屬性</th>
   <td>{{Glossary("Request header")}}</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Forbidden header name")}}</th>
   <td>no</td>
  </tr>
 </tbody>
</table>

<h2 id="語法">語法</h2>

<pre class="syntaxbox">X-Forwarded-For: &lt;client&gt;, &lt;proxy1&gt;, &lt;proxy2&gt;
</pre>

<h2 id="指令">指令</h2>

<dl>
 <dt>&lt;client&gt;</dt>
 <dd>用戶端的 IP 位置</dd>
 <dt>&lt;proxy1&gt;, &lt;proxy2&gt;</dt>
 <dd>如果請求用上了多個代理,則列出每個後續代理的 IP 地址。也就是說,最右邊的 IP 位置,是最新代理的 IP 位置;最左邊的 IP 位置,是用戶端原始來源的 IP 位置。</dd>
</dl>

<h2 id="示例">示例</h2>

<pre>X-Forwarded-For: 2001:db8:85a3:8d3:1319:8a2e:370:7348

X-Forwarded-For: 203.0.113.195

X-Forwarded-For: 203.0.113.195, 70.41.3.18, 150.172.238.178
</pre>

<p>其他非標準變體:</p>

<pre># Used for some Google services
X-ProxyUser-Ip: 203.0.113.19</pre>

<h2 id="規範">規範</h2>

<p>任何版本都沒有被標準化。標準化版本的標頭為 {{HTTPHeader("Forwarded")}}</p>

<h2 id="瀏覽器相容性">瀏覽器相容性</h2>



<p>{{Compat("http.headers.X-Forwarded-For")}}</p>

<h2 id="參見">參見</h2>

<ul>
 <li>{{HTTPHeader("Forwarded")}}</li>
 <li>{{HTTPHeader("X-Forwarded-Host")}}</li>
 <li>{{HTTPHeader("X-Forwarded-Proto")}}</li>
 <li>{{HTTPHeader("Via")}}</li>
</ul>