How to Set Up Custom Headers

You are here:
< Back

Setting Up Custom Headers

In some circumstance a user may need to set up a custom header, such as a Cache-Control header or an Expire header.

In this guide, we will set up custom headers over a JavaScript and CSS file, as an example.

Step 1

Log in to the WebAdmin Console via https://IP:7080, go to Virtual Hosts > Context, and create a new context.

Step 2

In the newly created context, set Type to Static.

Since the targeted files are JS and CSS, use regex to match all files of those types for URI, like so:


You can add more static file extensions, if you like, for example:


Set Location to $DOC_ROOT/$0. We need the $0 because URI uses regex.

Set Accessible to Yes.

Set Enable Expire to Yes.

Set Expires by Type to the following (15552000 seconds equals 180 days):

application/javascript=A15552000, text/css=A15552000

Set Header Operations to the following:

unset Cache-control
set Cache-control public, max-age=15552000

The unset cache-control line removes the previous cache control header, before the new one is set in the next line.

Save and restart.


You can look for the new response header from the browser’s development tool.

Adding Custom Headers

If more headers need to be added, the syntax and usage are similar to that of Apache’s mod_headers directives for supported operations.

Here’s an example that adds an X-Powered-By header:

The verified result: