Forum Discussion
Ben_Wilson_2412
Cirrus
Jul 11, 2013Changing HTTP Reponse status code
Hi,
I've been asked to change the reponse HTTP Status code for custom 404 pages to "404" instead of 200.
It looks like this is possible by checking if the request is for /404.jsp, capturing...
nitass
Employee
Jul 12, 2013We want the HTTP Status for this request to be 404.is it something like this?
Need to change the HTTP Status code. (spark's reply)
https://devcentral.f5.com/community/group/aft/2161382/asg/50
e.g.
[root@ve10:Active] config b virtual bar list
virtual bar {
snat automap
pool foo
destination 172.28.19.252: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 is_404 0
if { [HTTP::uri] eq "/error/404.jsp" } {
set is_404 1
}
}
when SERVER_CONNECTED {
TCP::collect 12
}
when SERVER_DATA {
if { $is_404 } {
set payload [TCP::payload 12]
regsub 200 $payload 404 payload
TCP::payload replace 0 12 $payload
}
TCP::release
TCP::collect 12
}
}
[root@ve10:Active] config ssldump -Aed -nni 0.0 port 80
New TCP connection 1: 172.28.20.17(38929) <-> 172.28.19.252(80)
1373613950.6180 (0.0018) C>S
---------------------------------------------------------------
GET /error/404.jsp HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Host: 172.28.19.252
Accept: */*
---------------------------------------------------------------
New TCP connection 2: 200.200.200.10(38929) <-> 200.200.200.101(80)
1373613950.6191 (0.0010) C>S
---------------------------------------------------------------
GET /error/404.jsp HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Host: 172.28.19.252
Accept: */*
---------------------------------------------------------------
1373613950.6211 (0.0020) S>C
---------------------------------------------------------------
HTTP/1.1 200 OK
Date: Fri, 12 Jul 2013 07:36:23 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Fri, 12 Jul 2013 07:35:31 GMT
ETag: "4185d1-1d-8e2db6c0"
Accept-Ranges: bytes
Content-Length: 29
Connection: close
Content-Type: text/plain; charset=UTF-8
this is /error/404.jsp file.
---------------------------------------------------------------
1373613950.6212 (0.0031) S>C
---------------------------------------------------------------
HTTP/1.1 404 OK
Date: Fri, 12 Jul 2013 07:36:23 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Fri, 12 Jul 2013 07:35:31 GMT
ETag: "4185d1-1d-8e2db6c0"
Accept-Ranges: bytes
Content-Length: 29
Connection: close
Content-Type: text/plain; charset=UTF-8
this is /error/404.jsp file.
---------------------------------------------------------------
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
