Forum Discussion
João_Assad_4295
Nimbostratus
Nov 14, 2005redirect POSTs bigger than 1MB
Hello,
I'd like to redirect POSTs bigger than 1MB to an error page, so I tried this:
when HTTP_REQUEST {
set method [HTTP::method]
set clen [HTTP::header Content-Length]
if { $method =="POST" and $clen > 1048576 } {
log local0. "over 1MB post: $uri - ($clen) [IP::client_addr]"
HTTP::respond 301 "Location" "http://[HTTP::host/errorpage.htm"
}
}The problem with that is that it will only redirect after the whole POST is sent to the server, I'd like the iRule to interrupt the client and redirect it to the error page immediately.
So I tried adding HTTP::close or TCP::close after the HTTP::respond, but then I got "Document contains no data" errors on the client.
So, Is there a way to make this work ?
Thanks.
15 Replies
- Jari_Hyttinen_1
Nimbostratus
This rule works with IE6 but not with Mozilla based browsers. Why is that ?
The client shows a alert "The document contains no data"
The rule is:
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/upload" } {
set method [HTTP::method]
set clen [HTTP::header Content-Length]
if { $method =="POST" and $clen > 40960 } {
log local0. "Over 40 kb post: ($clen) from [IP::client_addr]"
reject
HTTP::respond 307 "Location" "http://www.mydomain.com/xxx.html"
}
}
}
I have tried to add HTTP::close before HTTP::respond, but it doesn't effect anyway.
I also tried to change HTTP::respond line to
HTTP::respond 303 content "http://www.mydomain.com/xxx.html"
and it doesn't effect either. - Colin_Walker_12Historic F5 AccountIt's interesting that it won't work in Mozilla based browsers. It sounds like it has something to do with the way that the different browsers are handling the 307 response the BIG-IP is sending them. Mozilla isn't dropping immediately, which may have something to do with RFC adherence, but I'd have to dig more deeply into it to be sure.
I might recommend adding some logging statements to be sure that the rule is behaving the same in both scenarios, so you can be sure it's only the browser's interpretation of the response that changes. In which case, you'd have to identify what it takes to get Mozilla to drop the connection.
-Colin - bl0ndie_127134Historic F5 AccountPlease try adding the 'reject' after the HTTP::redirect.
- bl0ndie_127134Historic F5 Accounts/HTTP::redirect/HTTP::respond
- Jari_Hyttinen_1
Nimbostratus
Hi,
Finally I got this iRule working. The issue was to use discard not reject.
I don't excatly know the difference between these two commands,
but now it works almost great.
Now I have noticed that if client tries to send much more bigger file
(actually over 140 kilobytes) HTTP::respond does not work correctly.
I have added logging statements to the iRule and it seems to me that every step goes OK.
I have check the request log from the web server behind Big-IP
that the POST request has been discard by Big-IP. That is great,
but I want to send a real response to the client.
What could cause this behaviour?
Here is my current iRule:
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/upload" } {
set method [HTTP::method]
set clen [HTTP::header Content-Length]
if { $method =="POST" and $clen > 133120 } {
log local0. "Over 130 kb post: ($clen) from [IP::client_addr]"
discard
HTTP::close
HTTP::respond 307 "Location" "http://www.mydomain.com/xxx.html"
}
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects