In some use-cases, it may be useful to return a specific status code for certain asset or path on the CDN. The example in this article will assist in creating a rule to display a desired status code on a specific path.
In this example, an HTTP status code 404 will be generated on the path "/example/". This condition takes server protocol into consideration and if it is "HTTP/1.1" the CDN will apply the defined status code for the desired assets.
Creating the Rule
Verifying the Rule
-
Curl asset without rule
~$ curl -I http://foo.bar.netdna-cdn.com/example/ HTTP/1.1 200 OK Date: Sun, 25 Aug 2013 21:12:00 GMT Content-Type: text/html; charset=UTF-8 Content-Length: 12345 Connection: keep-alive Accept-Ranges: none Vary: Accept-Encoding,Cookie Pragma: public Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate Server: NetDNA-cache/2.2 X-Cache: MISS
-
Curl asset with rule
~$ curl -I http://foo.bar.netdna-cdn.com/example/ HTTP/1.1 404 Not Found Date: Sun, 25 Aug 2013 21:11:56 GMT Content-Type: text/html Content-Length: 169 Connection: keep-alive Server: NetDNA-cache/2.2
-
Resulting Nginx Configuration Block
location ^~ /example/ { if ($server_protocol = "HTTP/1.1") { return 404; }
We hope this article was helpful and as always, If there are any questions or concerns about any of the topics mentioned in this article, please feel free to reach out to support - we are available 24/7 by chat or email!