Forum Discussion
curl irule behavior
I have an irule that is as follows:
when HTTP_REQUEST { set var1 [getfield [HTTP::uri] "/" 2 ] log local0. "$var1" HTTP::header replace "Host" "https://$var1.host.domain.com:9090" log local0. "[HTTP::host]" HTTP::uri [substr [HTTP::uri] [expr ([string length $var1 ] + 1 )]] log local0. "Host and URI modified to: [HTTP::host][HTTP::uri]" }
In the log this appears to be working, : https://var1.host.domain.com:
With the following curl command: curl -k -v -H 'Authorization:HCP ' https://host.domain.com:9090/path1/var1/path2/path3
In Curl output I'm getting the following:
Host: host.domain.com ( would expect to see var1.host.domain.com ) < HTTP/1.1 503 Service Unavailable * Connection 0 to host host.domain.com left intact
- Stanislas_Piro2Cumulonimbus
Hi,
Host header must not contain protocol
HTTP::header replace "Host" "$var1.host.domain.com:9090"
- JnonNimbostratus
Sorry in the initial post I posted an incorrect curl command - that is corrected here along with additional improved formatting, and log details.
when HTTP_REQUEST { set var1 [getfield [HTTP::uri] "/" 2 ] log local0. "$var1" HTTP::header replace "Host" "https://$var1.host.domain.com:9090" log local0. "[HTTP::host]" HTTP::uri [substr [HTTP::uri] [expr ([string length $var1 ] + 1 )]] log local0. "Host and URI modified to: [HTTP::host][HTTP::uri]" }
Sorry I don't have access to any of the server logs. I'll work on trying to get some of those though.
Curl Command:
$ curl -k -v -H 'Authorization:HCP certString ' https://host.domain.com:9090/var1/path1/path2/path3 output: > GET /var1/path1/path2/path3 HTTP/1.1 ( would not expect to see var1 here ) > User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3 > Host: host.domain.com:9090 ( would expect this to be var1.host.domain.com:9090 )
LTM log: ( this looks as it should )
: var1 : https://var1.host.domain.com:9090 : Host and URI modified to: https://var1.host.domain.com:9090/path1/path2/path3
Can you try reformatting your irule code using the preformatted code feature? And perhaps add some more complete log output?
What does your server, if you have access to the logs, say the hostname is? Since in your iRule you're just forcing a Host header change instead of say, a redirect, I think it is normal for Curl to assume you're still at host.domain.com.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com