Skip to content

bind: improve header flag usage with tags#822

Merged
mmatczuk merged 3 commits intomainfrom
hg/improve_header_flag
Jun 3, 2024
Merged

bind: improve header flag usage with tags#822
mmatczuk merged 3 commits intomainfrom
hg/improve_header_flag

Conversation

@Choraden
Copy link
Contributor

    -H, --header <header> (env FORWARDER_HEADER)
        Add or remove HTTP request headers. 
        
        Use the format:
        - name:value to add a header
        - name; to set the header to empty value
        - -name to remove the header
        - -name* to remove headers by prefix
        
        The header name will be normalized to canonical form. The header value should not contain any newlines or
        carriage returns. The flag can be specified multiple times. The following example removes the User-Agent
        header and all headers starting with X-. 
        
        -H "-User-Agent" -H "-X-*"

Choraden added 3 commits May 29, 2024 18:21
The Host header is special and cannot be modified.

Forwarder:

2024/05/29 16:19:50.958997 [INFO] configuration
header="Host:example.com"
...
2024/05/29 16:19:50.959097 [proxy] [INFO] no upstream proxy specified
2024/05/29 16:19:50.959098 [proxy] [INFO] localhost proxying mode=deny
2024/05/29 16:19:50.959349 [proxy] [INFO] PROXY server listen address=[::]:3128 protocol=http
2024/05/29 16:19:50.959440 [api] [INFO] HTTP server listen address=[::]:10000 protocol=http
2024/05/29 16:20:08.064039 [proxy] [DEBUG] accepted connection from 192.168.127.1:20458
2024/05/29 16:20:08.064212 [proxy] [DEBUG] [1-e625c0c2] opening connection to tcp httpbin:8080
w2024/05/29 16:20:08.064599 [proxy] [DEBUG] [1-e625c0c2] connection to tcp httpbin:8080 established duration=371.459µs
y2024/05/29 16:20:08.064814 [proxy] [INFO] [1-e625c0c2] GET http://httpbin:8080/status/200 status=200 duration=666.084µs
GET http://httpbin:8080/status/200 HTTP/1.1
Host: httpbin:8080
Content-Length: 0
Accept: */*
User-Agent: curl/8.6.0
Via: 1.1 forwarder-d922bb2844c309a350b1
X-Forwarded-For: 192.168.127.1
X-Forwarded-Host: httpbin:8080
X-Forwarded-Proto: http
X-Forwarded-Url: http://httpbin:8080/status/200

HTTP/1.1 200 OK
Content-Length: 0
Date: Wed, 29 May 2024 16:20:08 GMT

HTTPBIN:

2024/05/29 16:20:08.064729 [server] [INFO] GET /status/200 status=200 duration=4.5µs
GET /status/200 HTTP/1.1
Host: httpbin:8080
Content-Length: 0
Accept: */*
Accept-Encoding: gzip
User-Agent: curl/8.6.0
Via: 1.1 forwarder-d922bb2844c309a350b1
X-Forwarded-For: 192.168.127.1
X-Forwarded-Host: httpbin:8080
X-Forwarded-Proto: http
X-Forwarded-Url: http://httpbin:8080/status/200
@mmatczuk mmatczuk merged commit 2284bc3 into main Jun 3, 2024
@mmatczuk mmatczuk deleted the hg/improve_header_flag branch June 3, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants