Skip to content

Commit

Permalink
Passing Host header instead of X-Forwarded-Host
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveEasley committed Jun 16, 2016
1 parent ed5333a commit 00dc531
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 1 addition & 10 deletions src/proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,6 @@ proxy_curl(VRT_CTX, struct proxy_request *req, const struct director *dir,
struct curl_slist *headers = NULL;
char *wshdr = NULL;

if (be->hosthdr) {
wshdr = WS_Printf(ctx->ws, "Host: %s", be->hosthdr);
headers = curl_slist_append(headers, wshdr);
}

for (int u = 0; u < ctx->http_req->nhd; u++) {
const txt hdr = ctx->http_req->hd[u];

Expand All @@ -340,11 +335,7 @@ proxy_curl(VRT_CTX, struct proxy_request *req, const struct director *dir,
headers = curl_slist_append(headers, wshdr);
}
else if (u >= HTTP_HDR_FIRST) {
if (is_header(&hdr, H_Host)) {
wshdr = WS_Printf(ctx->ws, "X-Forwarded-Host: %s", (hdr.b + H_Host[0] + 1));
headers = curl_slist_append(headers, wshdr);
}
else if (is_header(&hdr, H_Via) || is_header(&hdr, H_Content_Length)) {
if (is_header(&hdr, H_Via) || is_header(&hdr, H_Content_Length)) {
continue;
}
else if (is_header(&hdr, H_Accept_Encoding)) {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/a03.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ varnishtest "Test proxy headers"
server s1 {
rxreq
expect req.method == "GET"
expect req.http.Host == "foo.com"
expect req.http.Via == {HTTP/1.1 VMOD-HeaderProxy}
expect req.http.X-Forwarded-Method == "POST"
expect req.http.X-Forwarded-Url == {/foo}
expect req.http.X-Forwarded-Host == "foo.com"
txresp -hdr "Content-Type: application/json" -body "{}"

accept
Expand Down

0 comments on commit 00dc531

Please sign in to comment.