Forum Discussion
101 connection reset
Hi all.
Firstly, i have to thank to all contributors in this forum, because they've saved my life a lot of times.
Today i have a problem with one irule.
I am writing an irule that concern this concepts:
First. If the destiny does not contain an explicit domain and uri is empty, you have to redirect the request to some place, whit the source host as uri,
Second: If it has an uri, i have to replace the host with an especific host leave the original uri without modification.
As i'm spanish and i'm not sure if i'm explained me correctly there it go an example.
1.- I the domain it is not www.ejemplo.com and the uri have not content.
Example:
http://www.noejemplo.com/ --> http://www.ejemplo.com/noejemplo.com
2.- If the request content and uri:
Example:
http://www.noejemplo.com/xyz --> http://www.ejemplo.com/xyz
In my irule, the second part run perfectly but the first option give me an error "101 error connection reset".
As you'll see below i've put the response in a log to trace it.
I do not know if you had found some error like this.
This is my Irule:
when HTTP_REQUEST {
set host_debug 1
set newhost "www.ejemplo.com"
set hostname [getfield [HTTP::host] ":" 1]
set suri [getfield [HTTP::host] ":" 1]
set ouri [HTTP::uri]
if { (not ([HTTP::host] equals $newhost)) and (not ([HTTP::uri] equals "/"))
}
{
HTTP::header replace Host $newhost
if {$host_debug}{log local0. "[HTTP::host]: First Case: Replaced Host header with $newhost$ouri"}
}
elseif { (not ([HTTP::host] equals $newhost))
}
{
HTTP::header replace Host $newhost/$suri
if {$host_debug}{log local0. "[HTTP::host]: Second case: Replaced Host header with $newhost/$suri."}
}
}
12 Replies
- avaj_44503
Nimbostratus
Sorry i've forgot something, Thanks in advance. :-) - What_Lies_Bene1
Cirrostratus
Can you please clarify which part of the iRule is the first part (the problem) and which is the second? - What_Lies_Bene1
Cirrostratus
Note that in this line, you are adding the URI to the HTTP Host header which you shouldn't be doing;HTTP::header replace Host $newhost/$suri
- nitass
Employee
not sure if you want redirection or rewriting.[root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { set newhost "www.ejemplo.com" if { not ([HTTP::host] equals $newhost ) } { if { [HTTP::uri] equals "/" } { HTTP::redirect "http://$newhost/[string map {www. ""} [HTTP::host]]" } else { HTTP::redirect "http://$newhost[HTTP::uri]" } } } } [root@ve10:Active] config curl -I http://www.noejemplo.com/ HTTP/1.0 302 Found Location: http://www.ejemplo.com/noejemplo.com Server: BigIP Connection: Keep-Alive Content-Length: 0 [root@ve10:Active] config curl -I http://www.noejemplo.com/xyz HTTP/1.0 302 Found Location: http://www.ejemplo.com/xyz Server: BigIP Connection: Keep-Alive Content-Length: 0
- nitass
Employee
this is rewriting.[root@ve10:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.19.79:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b pool foo list pool foo { members 200.200.200.101:80 {} } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { set newhost "www.ejemplo.com" if { not ([HTTP::host] equals $newhost ) } { if { [HTTP::uri] equals "/" } { HTTP::header replace Host $newhost HTTP::uri "/[string map {www. ""} [HTTP::host]]" } else { HTTP::header replace Host $newhost } } } } [root@ve10:Active] config ssldump -Aed -nni 0.0 port 80 New TCP connection 1: 172.28.20.11(59583) <-> 172.28.19.79(80) 1351506625.0959 (0.0011) C>S --------------------------------------------------------------- HEAD / HTTP/1.1 User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Accept: */* Host: www.noejemplo.com --------------------------------------------------------------- New TCP connection 2: 200.200.200.10(59583) <-> 200.200.200.101(80) 1351506625.0986 (0.0008) C>S --------------------------------------------------------------- HEAD /noejemplo.com HTTP/1.1 User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Accept: */* Host: www.ejemplo.com --------------------------------------------------------------- [root@ve10:Active] config ssldump -Aed -nni 0.0 port 80 New TCP connection 1: 172.28.20.11(59584) <-> 172.28.19.79(80) 1351506657.3599 (0.0012) C>S --------------------------------------------------------------- HEAD /xyz HTTP/1.1 User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Accept: */* Host: www.noejemplo.com --------------------------------------------------------------- New TCP connection 2: 200.200.200.10(59584) <-> 200.200.200.101(80) 1351506657.3607 (0.0007) C>S --------------------------------------------------------------- HEAD /xyz HTTP/1.1 User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Accept: */* Host: www.ejemplo.com ---------------------------------------------------------------
- avaj_44503
Nimbostratus
Hi all, - avaj_44503
Nimbostratus
Hi all, - What_Lies_Bene1
Cirrostratus
Can you show us what you changed pleased and then we'll be able to comment. - avaj_44503
Nimbostratus
Hi Steve, - nitass
Employee
i do not know why you got 101 connection reset. if host header is wrong, i think we should receive http 400 status code.[root@ve10:Active] config curl -I http://200.200.200.101/something -H "Host: www.ejemplo.com/noejemplo.com" HTTP/1.1 400 Bad Request Date: Mon, 29 Oct 2012 12:47:23 GMT Server: Apache/2.2.3 (CentOS) Connection: close Content-Type: text/html; charset=iso-8859-1
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