華為云計(jì)算 云知識(shí) 如何配置CDN用戶(hù)回源請(qǐng)求URL的頭部信息
如何配置CDN用戶(hù)回源請(qǐng)求URL的頭部信息

 【CDN流量?jī)r(jià)格】 

如果您需要修改用戶(hù)回源請(qǐng)求URL中的頭部信息,可以通過(guò)配置回源請(qǐng)求頭參數(shù)來(lái)實(shí)現(xiàn)。本章幫您了解回源請(qǐng)求頭的配置方法。

背景信息

當(dāng)用戶(hù)請(qǐng)求的內(nèi)容CDN節(jié)點(diǎn)無(wú)緩存時(shí),CDN會(huì)回源請(qǐng)求資源。如果您想要改寫(xiě)用戶(hù)回源請(qǐng)求URL的頭部信息,可以在CDN控制臺(tái)完成相關(guān)配置。

HTTP消息頭,是指在超文本傳輸協(xié)議(Hypertext Transfer Protocol,HTTP)的請(qǐng)求和響應(yīng)消息中的消息頭部分,定義了HTTP傳輸過(guò)程中的具體參數(shù)。

注意事項(xiàng)

回源請(qǐng)求頭配置只會(huì)影響通過(guò)CDN回源的HTTP消息,對(duì)于CDN節(jié)點(diǎn)直接響應(yīng)給用戶(hù)的HTTP消息不做修改。

同一個(gè)請(qǐng)求頭不允許同時(shí)存在兩個(gè)不同的取值。

 

操作步驟

登錄華為云控制臺(tái),在控制臺(tái)首頁(yè)中選擇“CDN與智能邊緣 > CDN”,進(jìn)入CDN控制臺(tái)。

在左側(cè)菜單欄中,選擇域名管理

在域名列表中,單擊需要修改的域名或域名所在行的“設(shè)置”,進(jìn)入域名配置頁(yè)面。

選擇“回源配置”頁(yè)簽。

在回源請(qǐng)求頭配置模塊,單擊“添加”按鈕。

配置回源請(qǐng)求頭信息

  • 添加:在CDN側(cè)添加回源請(qǐng)求頭參數(shù),用來(lái)改寫(xiě)用戶(hù)請(qǐng)求URL中的頭部信息。

配置項(xiàng)

示例

說(shuō)明

請(qǐng)求頭操作

設(shè)置

在回源HTTP請(qǐng)求中增加指定的請(qǐng)求頭參數(shù)。

  • 如果用戶(hù)請(qǐng)求URL中攜帶X-test參數(shù),取值111。CDN側(cè)設(shè)置的X-test取值為aaa,那么回源時(shí)X-test的取值為aaa。
  • 如果用戶(hù)請(qǐng)求URL中沒(méi)有攜帶X-test參數(shù),那么回源時(shí)增加X(jué)-test,取值為aaa。

刪除

刪除用戶(hù)請(qǐng)求URL中已經(jīng)存在的頭部信息。

  • 如果用戶(hù)請(qǐng)求URL中攜帶X-test參數(shù),回源時(shí)會(huì)刪除該參數(shù)。

請(qǐng)求頭參數(shù)

X-test

  • 長(zhǎng)度1~64。
  • 由數(shù)字0 - 9、字符a - z、A - Z,及特殊符“-”組成。

請(qǐng)求頭取值

aaa

  • 長(zhǎng)度為1~512。
  • 由數(shù)字0 - 9、字符a - z、A - Z,及特殊符"*"、“.”、“-”、“_”組成。
  • 不支持變量配置,如:$client_ip,$remote_port等。
  • 編輯:修改當(dāng)前回源請(qǐng)求頭取值或操作

單擊“操作”列“編輯”按鈕,彈框如下:

配置項(xiàng)

示例

說(shuō)明

請(qǐng)求頭操作

設(shè)置

在回源HTTP請(qǐng)求中增加指定的請(qǐng)求頭參數(shù)。

  • 如果用戶(hù)請(qǐng)求URL中攜帶X-test參數(shù),取值111。CDN側(cè)設(shè)置的X-test取值為aaa,那么回源時(shí)X-test的取值為aaa。
  • 如果用戶(hù)請(qǐng)求URL中沒(méi)有攜帶X-test參數(shù),那么回源時(shí)增加X(jué)-test,取值為aaa。

刪除

刪除用戶(hù)請(qǐng)求URL中已經(jīng)存在的頭部信息。

  • 如果用戶(hù)請(qǐng)求URL中攜帶X-test參數(shù),回源時(shí)會(huì)刪除該參數(shù)。

請(qǐng)求頭參數(shù)

X-test

此處無(wú)法修改。

請(qǐng)求頭取值

aaa

  • 長(zhǎng)度為1~512。
  • 由數(shù)字0 - 9、字符a - z、A - Z,及特殊符"*"、“.”、“-”、“_”組成。
  • 不支持變量配置,如:$client_ip,$remote_port等。

單擊確定,完成配置。

說(shuō)明:如果您的域名服務(wù)范圍為全球或中國(guó)大陸境外時(shí),用戶(hù)請(qǐng)求頭“Accept-Encoding”如果包含多個(gè)值,CDN回源時(shí)僅透?jìng)鳌癎zip”。
 

配置示例

加速域名“www.example.com”的回源請(qǐng)求頭設(shè)置如下:

當(dāng)用戶(hù)訪問(wèn)“http://www.example.com/abc.jpg”文件時(shí),CDN節(jié)點(diǎn)沒(méi)有緩存該資源,CDN回源請(qǐng)求資源?;卦磿r(shí)增加“X-cdn頭部”,同時(shí)刪除“X-test頭部”。

使用限制

如果您的后臺(tái)存在特殊配置,暫不支持配置Content-Type、Cache-Control、Expires、Content-Language、Content-Disposition。

目前不支持改寫(xiě)以下標(biāo)準(zhǔn)頭部信息:

Origin

accept-ch

clear-site-data

push-policy

WsTag

Tcp-Retrans

access-control-allow-methods

access-control-max-age

vary

Date

X-Forward-Type

width

Age

ETag

Purge-Extra

X-Cacheable

access-control-allow-headers

Front-End-Https

ping-to

content-range

cross-origin-opener-policy

Location

viewport-width

Mime-Version

Proxy-Support

X-Resp-Time

If-Range

sec-fetch-dest

device-memory

X-Mem-Url

Cdn-Src-Ip

ping-from

Allow

X-Url-Blackwhite-List

early-data

Sec-WebSocket-Extensions

if-unmodified-since

X-Forward-Uri

Conf-File

x-download-options

X-Error-Status

Negotiate

x-permitted-cross-domain-policies

service-worker-allowed

X-Appa

x-firefox-spdy

content-dpr

X-Miss-Times-Limit

X-Bwctrl-Limit

X-Bwctrl-Para

X-Max-Conns

nel

public-key-pins-report-only

X-MAA-Alias

Sec-WebSocket-Location

X-Cache-2

Authorization

Expect

last-event-id

Sec-WebSocket-Key

X-Refresh-Pattern

forwarded

X-Local-Ip

Sec-WebSocket-Protocol

feature-policy

cross-origin-resource-policy

Request-Range

Conf-Other

strict-transport-security

signed-headers

Cdn-Server-Ip

Sec-WebSocket-Version

accept

X-Black-List

content-location

sourcemap

Partition-Block-Size

Proxy-Authentication-Info

cross-origin-embedder-policy

X-Request-Id

x-dns-prefetch-control

if-none-match

If-Non-Match

Public

X-White-List

x-ua-compatible

Keep-Alive

Transfer-Encoding

alt-svc

max-age

Last-Modified

x-xss-protection

Sec-WebSocket-Nonce

dnt

Link

x-robots-tag

Key

expect-ct

sec-fetch-site

access-control-request-headers

X-Error-URL

X-Log-Url

content-encoding

X-Times-Limit

X-Appa-Origin

X-Miss-Rate-Limit

X-IP-Region

Dynamic

X-Squid-Error

From

accept-ch-lifetime

X-MAA-Auth

Connection

X-Via-CDN

Max-Forwards

Upgrade

sec-fetch-user

content-security-policy-report-only

Pragma

save-data

X-Client-Ip

Cdn-Qos

x-powered-by

X-Forward-Measured

accept-push-policy

server

large-allocation

X-Request-Uri

X-Forward-Ip

Host

Proxy-Authenticate

X-Request-Url

X-Cache-Lookup

Conf-Option

X-Forward-Host

upgrade-insecure-requests

X-Accelerator-Vary

signature

X-Ip-Blackwhite-List

X-Cdn-Src-Port

Sec-WebSocket-Draft

Sec-WebSocket-Origin

X-IP-Region-CN

public-key-pins

Ws-Hdr

If-Match

Proxy-Authorization

X-Rate-Limit

sec-fetch-mode

trailer

X-Rewrite-Url

Via

X-Cache

X-Mgr-Traffic

accept-signature

Warning

x-forwarded-proto

If-Modified-Since

Authentication-Info

access-control-request-method

Content-Length

x-frame-options(xfo)

Range

A_Dynamic

te

x-forwarded-host

Title

WWW-Authenticate

tk

X-Query-Key

accept-charset

access-control-allow-origin

accept-ranges

report-to

access-control-expose-headers

x-content-type-options

Proxy-Connection

server-timing

Retry-After

x-requested-with

X-No-Referer

X-Forward-Peer

Sec-WebSocket-Accept

X-Forwarded-For

Conf-Err-Host

Sec-WebSocket-Key2

access-control-allow-credentials

X-Denyattack-Dynconf

referer-policy

Sec-WebSocket-Key1

content-security-policy

timing-allow-origin

X-DNS-Time

Conf-File-List

X-expireURL

x-pingback

Purge-Domain

dpr

-

-


版權(quán)聲明:本文章文字內(nèi)容來(lái)自第三方投稿,版權(quán)歸原始作者所有。本網(wǎng)站不擁有其版權(quán),也不承擔(dān)文字內(nèi)容、信息或資料帶來(lái)的版權(quán)歸屬問(wèn)題或爭(zhēng)議。如有侵權(quán),請(qǐng)聯(lián)系contentedit@huawei.com,本網(wǎng)站有權(quán)在核實(shí)確屬侵權(quán)后,予以刪除文章。