How to Add a Custom HTTP Header to All Sites on a Plesk Server

Adding custom headers is a useful way to identify, trace, or control web traffic across a hosted environment. This guide walks through the process of adding the HTTP header X-Hosted-By: ExampleHost to all websites running on a Plesk server, across both nginx and Apache layers.


Why Add a Custom Header?

Custom HTTP headers can:

  • Identify the infrastructure powering your site (e.g., for branding or tracing)
  • Assist in diagnostics or security logging
  • Be used for custom caching or CDN logic

Step-by-Step: Add Header in nginx

Step 1: Copy the nginx Template

First, copy the default Plesk template into a custom directory:

Step 2: Edit the Template

Open the copied file:

Locate the block that outputs header directives, such as:

Insert your custom header right after:

Step 3: Rebuild nginx Configurations

Step 4: Restart nginx


Step-by-Step: Add Header in Apache

Step 1: Copy the Apache Template

Step 2: Edit the Template

Look for the following section:

Insert the new header block immediately after:

Step 3: Rebuild Apache Configurations

Step 4: Restart Apache


Verifying the Header

To confirm the header has been successfully applied:

You should see:


Optional: Per-Domain Configuration via Plesk GUI

If you prefer to apply the header only to certain domains:

  1. Log in to the Plesk control panel
  2. Navigate to Domains → [Your Domain] → Apache & nginx Settings
  3. Under Additional nginx directives, add:

  1. Under Additional Apache directives, add:

  1. Click Apply Changes

By customizing the Plesk templates, you can ensure consistency across all hosted sites while still allowing per-domain overrides when needed. This is a clean and manageable way to implement cross-server headers like X-Hosted-By, security headers, or custom CDN triggers.

Have a project or a problem?

Talk with a senior engineer for practical recommendations—no obligation.

Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Categories

Get a free consultation from Reliable Penguin

Submit the form—or for immediate service call 866-649-7984.