Header Rewrite

Chute can rewrite request and response headers before they are forwarded to the server or client.

Mutiple rules could be applied for one single request.

Example:

[Header Rewrite]
^http://example\.com.* header-add DNT 1
^http://example\.com.* header-del Cookie
^http://example\.com.* header-replace User-Agent Unknown
^http://example\.com.* header-response-add X-Server rack3
^http://example\.com.* header-response-del X-Powered-By
^http://example\.com.* header-response-replace Server nginx

The rewrite rule consists 4 parts: URL regular expression, action type, header field and value.

Notice: The URL regular expression must match the complete request URL, not just a substring of it. Patterns should usually end with .* so that URLs with any path and query string are matched.

Request vs Response Headers

Actions prefixed with header- apply to request headers (from client to server). Actions prefixed with header-response- apply to response headers (from server to client).

An optional Surge-style direction prefix http-request / http-response placed before the URL regular expression is also accepted, e.g. http-request ^http://example\.com.* header-replace Accept-Language en-us.

header-add

Set a header field in the request header to the given value. If the header field already exists, it is overwritten.

Example:

[Header Rewrite]
^http://example\.com.* header-add DNT 1

Before:
GET /index.html HTTP/1.1
Host: example.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
Accept-Language: en-us
Accept-Encoding: gzip, deflate

After:
GET /index.html HTTP/1.1
Host: example.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
Accept-Language: en-us
Accept-Encoding: gzip, deflate
DNT: 1

header-del

Delete a header line from the request header.

Example:

[Header Rewrite]
^http://example\.com.* header-del DNT

Before:
GET /index.html HTTP/1.1
Host: example.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
Accept-Language: en-us
Accept-Encoding: gzip, deflate
DNT: 1

After:
GET /index.html HTTP/1.1
Host: example.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
Accept-Language: en-us
Accept-Encoding: gzip, deflate

header-replace

Replace a header value in the request header. If the header field doesn't exist, nothing happens.

Example:

[Header Rewrite]
^http://example\.com.* header-replace DNT 1

Before:
GET /index.html HTTP/1.1
Host: example.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
Accept-Language: en-us
Accept-Encoding: gzip, deflate
DNT: 0

After:
GET /index.html HTTP/1.1
Host: example.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
Accept-Language: en-us
Accept-Encoding: gzip, deflate
DNT: 1

Notice: header-replace only works when the header field already exists. To set a header field regardless of whether it exists, use header-add — it overwrites any existing field with the same name, so combining header-del and header-add is unnecessary.

S. Smart Rabbit LLC © All Rights Reserved            updated 2026-08-18 11:57:36

results matching ""

    No results matching ""