1. Home
  2. Accelerator
  3. Custom Headers in the Snapt Aria Website Accelerator

Custom Headers in the Snapt Aria Website Accelerator

You occasionally need to collect certain information at your application that cannot–and even shouldn’t–be passed through GET or POST methods.

For example, if your server is behind a reverse proxy (and such is the case with Snapt Aria), you might want to know which part of your infrastructure handled over the request to later be able to perform certain analytics. Or perhaps you are a protocol designer and are testing things out, and want to flag some processes to let your application know you’re on a sandbox and can relax – or enforce – certain restrictions.

Whichever the case, you can apply custom HTTP headers through the web accelerator settings.

Customizing headers is an advanced setting, so bear in mind there are a series of considerations, including such as security concerns, that you must address when implementing application protocols or creating new parameters.

For more information see RFC 6648 by the Internet Engineering Task Force (ETF).

How to Add Custom Headers

If the server to which you want to pass the custom header is being cached, you can add the custom herders right from the Cache Profile.

Navigate to:

Accelerator > Caching > Cache Profile

Under the View Profiles tab, click on the Settings button for the Cache Profile you intend to change (most probably Default).

In the Options pane, you’ll find the Custom Headers [Advanced] field where you can enter, one per line, your custom headers.

Click the Save button.

Example: Source IP with X-Forwarded-For(XFF)

Any connection through the proxy would only reveal the originating IP address of the proxy server, namely, your Snapt Aria instance.

To address this issue, you add an X-Forwarded-For (XFF) HTTP header field, which is a method commonly used to identify the originating IP address of a client that’s connecting to a web server through an HTTP proxy or load balancer.

Navigate to:

Accelerator > Caching > Caching Profiles

Go under:

View Profiles tab > Cache Profiles pane > [your profile] line > Settings button

Once in the Options pane, add to the Custom Headers [Advanced] filed:

X-Real-IP $remote_addr
X-Forwarded-For $proxy_add_x_forwarded_for

Non Cached Server

Servers that are not cached therefore don’t make use of Cache Profiles and will need to be updated in order to apply custom headers.

Step 1: Add a New Profile

First, you’ll create your Caching Profile.

Navigate to:

Accelerator > Caching > Caching Profiles

Under the Add Profile tab, give a Name to your profile.

Click the Add new profile button.

Step 2: Edit Responses Cache

To render the cache profile as a non-cached profile, you will need to remove the 200 302 1d line from the out of Responses Cache [Advanced] field.

Step 3: Add Custom Headers

You can now add your custom headers.

Edit the Custom Headers [Advanced] field accordingly.

Click the Save button.

You’ll finally link the Cache Profile you’ve have created to an HTTP server.

Navigate to:

Accelerator > HTTP Servers (Frontend)

Under the View Servers tab, click on the Settings button for the server you want to link your Cache Profile to.

Under the Acceleration Options pane, set the Default Cache filed to STATIC [/data/accel/cache]and choose your newly created Cache Profile.

Click the Save button.

Updated on April 9, 2020

Was this article helpful?

Related Articles