Forum Discussion
Inserting 301 returns blank page
The rule below returns a 301 but it also returns a blank page, so somehow my redirect to "http://synergycitizens.org[HTTP::uri]" isn't working. The host names below are not real, but the rule below accurately reflects my existing rule. What am I missing here? Thanks.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"www." -
"synergycitizens.net" -
"synergycitizens.com" -
"synergycitizens.mobi" -
"synergycitizens.net" -
"citizensforsynergy.org" -
"citizensforsynergy.net" -
"citizensforsynergy.com" -
"synergyscitizen.org" -
"synergyscitizen.com" -
"synergycitizen.net" -
"synergycitizen.com" -
"synergy-citizen.org" -
"synergy-citizen.net" -
"synergy-citizen.com" -
"synergy-citizens.org" -
"synergy-citizens.net" -
"synergy-citizens.com" -
"synergycitizen.org" { HTTP::respond 301 "http://synergycitizens.org[HTTP::uri]" }
}
}
15 Replies
- Peter_72728
Nimbostratus
What do you mean by "it also returns a blank page"? Does the browser correctly process the 301 by requesting the new URI? And then the resulting page is a 200 but it's blank?Also... What's the value of [HTTP::uri]? What is the actual location that the 301 sends the browser to? And is there a (non-blank) page at that URL?
- DaveC_53879
Nimbostratus
It returns page cannot be displayed, in othwer words, nothing. The redirect does not work. The value of [HTTP::uri] could be anything or nothing. All I want to change in the original request is the hostname while returning a 301 instead of a 302. A straight http redirect works fine. - Peter_72728
Nimbostratus
ok...I wasn't getting that. I'd recommend using Fiddler or Charles to see the actual response. "Page cannot be displayed" is so vague...and very uninformative when trying to debug. :)My first thought is that you have an error occurring in the iRule and the connection is getting dropped. I've had this happen in many occasions when the path through my iRules resulted in a second redirect instruction being sent.
Have you checked the logs to see if they shed any light in the subject?
- hoolio
Cirrostratus
Yep, checking /var/log/ltm for TCL errors would be a good start. You can also try testing with curl from the LTM command line:
curl -v 1.1.1.1 -H "Host: my_host.example.com"
Aaron - DaveC_53879
Nimbostratus
Thanks Peter and Aaron for responding. I was away for a few days. There's nothing being recorded in /var/log/ltm for this rule. It returns a 301 which I can see in Fiddler, but it is not redirecting to the working URL as I need it to do, which is why I get Internet Explorer cannot display the webpage, because there is none except at the redirect URL.
{ HTTP::respond 301 "http://synergycitizens.org[HTTP::uri]" }
I'm currently using a straight HTTP::redirect, which redirects properly, but returns a 302 and my WebDev guys need it to return a 301 while still redirecting. Perhaps I'm posing the question incorrectly.
Dave - hoolio
Cirrostratus
Hi Dave,
Can you add an asterisk to the www. entry and a log entry before retesting?when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "www.*" - "synergycitizens.net" - "synergycitizens.com" - "synergycitizens.mobi" - "synergycitizens.net" - "citizensforsynergy.org" - "citizensforsynergy.net" - "citizensforsynergy.com" - "synergyscitizen.org" - "synergyscitizen.com" - "synergycitizen.net" - "synergycitizen.com" - "synergy-citizen.org" - "synergy-citizen.net" - "synergy-citizen.com" - "synergy-citizens.org" - "synergy-citizens.net" - "synergy-citizens.com" - "synergycitizen.org" { HTTP::respond 301 "http://synergycitizens.org[HTTP::uri]" log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting to http://synergycitizens.org[HTTP::uri]" } default { log local0. "[IP::client_addr]:[TCP::client_port]: Doing nothing for [HTTP::host][HTTP::uri]" } } }
Can you clarify what happens in the debug logging when you get a 'cannot display the page' error in IE?
Aaron - DaveC_53879
Nimbostratus
Aaron,
Making progress. I setup a test site to make this managable. I edited your rule to reflect the test site.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "www.*" { HTTP::respond 301 "http://ddcpoc.com[HTTP::uri]" log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting to http://ddcpoc.com[HTTP::uri]" } default { log local0. "[IP::client_addr]:[TCP::client_port]: Doing nothing for [HTTP::host][HTTP::uri]" } } }
Log entry for http://ddcpoc.com/hello.txt
Aug 8 12:49:06 tmm tmm[1710]: Rule ddcpoc_301_redirect : 216.2.59.100:32122: Doing nothing for ddcpoc.com/hello.txt
Log entry for http://www.ddcpoc.com/hello.txt;
Aug 8 12:49:15 tmm tmm[1710]: Rule ddcpoc_301_redirect : 216.2.59.100:32251: Redirecting to http://ddcpoc.com/hello.txt
But it doesn't redirect. I still show the original URL in the address window and IE says page cannot be displayed. Firefox returns a completely blank page with no errors.
In Fiddler, I see;
301 HTTP www.ddcpoc.com /hello.txt 0 iexplore:1712
For the test site, www actually works if I remove the irule.
It looks like it should be working, but...
Thanks a lot for your help.
Dave - hoolio
Cirrostratus
I think the iRule is working as designed--it's redirecting www.* correctly. I think the issue is with requests sent to the pool with a host header of ddcpoc.com. If you make a request from LTM using curl, does it work?
curl -v 1.1.1.1/hello.txt -H "Host: ddcpoc.com"
Replace 1.1.1.1 with the pool member address.
Aaron - DaveC_53879
Nimbostratus
That worked OK. See below. I don't doubt that the F5 is redirecting, but the browser doesn't seem to be happy with what it's getting back. I just don't know what that is. Could it be a version issue? I'm running 9.4.6.
* About to connect() to 10.70.70.91 port 80
* Trying 10.70.70.91... connected
* Connected to 10.70.70.91 (10.70.70.91) port 80
> GET /hello.txt HTTP/1.1
> User-Agent: curl/7.15.3 (i686-redhat-linux-gnu) libcurl/7.15.3 OpenSSL/0.9.7l zlib/1.1.4
> Accept: */*
> Host: ddcpoc.com
>
< HTTP/1.1 200 OK
< Content-Type: text/plain
< Last-Modified: Mon, 08 Aug 2011 14:05:44 GMT
< Accept-Ranges: bytes
< ETag: "aaf644d455cc1:0"
< Server: Microsoft-IIS/7.0
< Date: Mon, 08 Aug 2011 20:03:52 GMT
< Content-Length: 10
Connection 0 to host 10.70.70.91 left intact
* Closing connection 0
Dave - DaveC_53879
Nimbostratus
Aaron,
Below are Wireshark captures of with and w/o www. The www request is not doing anything except returning the 301. It is not returning the redirect or the persistence cookie. Is this expected behavior?
With www;
BCEv@
Fdd@yPEe-P@)iGET /hello.txt HTTP/1.1
Accept: image/jpeg, image/gif, image/pjpeg, application/x-ms-application, application/xaml+xml, application/x-ms-xbap, */*
Accept-Language: en-US
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727)
Accept-Encoding: gzip, deflate
Host: www.ddcpoc.com
Connection: Keep-Alive
CBE@m@y
FddPe-EyP):HTTP/1.0 301 Moved Permanently
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
________________________________________________________________________________________________________
Without www;
BCEv@
Fdd@yP7P@)eGET /hello.txt HTTP/1.1
Accept: image/jpeg, image/gif, image/pjpeg, application/x-ms-application, application/xaml+xml, application/x-ms-xbap, */*
Accept-Language: en-US
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727)
Accept-Encoding: gzip, deflate
Host: ddcpoc.com
Connection: Keep-Alive
CBE[@h@y
FddP7cPHTTP/1.1 200 OK
Content-Type: text/plain
Last-Modified: Mon, 08 Aug 2011 14:05:44 GMT
Accept-Ranges: bytes
ETag: "aaf644d455cc1:0"
Server: Microsoft-IIS/7.0
Date: Tue, 09 Aug 2011 13:35:33 GMT
Content-Length: 10
Set-Cookie: cookie_20=w6kqN0rnyKHSgn88ypggjDSkaLZsHrBeiviqjzef1SvezbovkWO8gk/UZgSPLAtk7hv7o66oLYBBbww=; expires=Tue, 09-Aug-2011 13:55:33 GMT; path=/
SUccess!!!
Dave
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
