Skip to the content

Contact usFree tools · No signup · Files stay on your device

Website Tools

How to remove the X-Powered-By header with Cloudflare

How to remove the X-Powered-By header with Cloudflare

The X-Powered-By header is a line a server adds to every response to announce what it runs, such as X-Powered-By: PHP/8.2.12, Express or Next.js. Visitors never see it, but scanners and attackers do, and it tells them which exploits to try first. If your site is behind Cloudflare you can remove the header at the edge without touching your server, and you can fix it at the origin as well.

This guide shows both ways, and uses the free Security Headers Checker to prove the header is gone.

First, confirm the header is there

  1. Open Security Headers Checker.
  2. Enter your site's address and press Scan headers.
  3. Find the row "Server / X-Powered-By" in Score breakdown. It carries 5 points. If the header is present, the result says "Leaks versions" and shows something like X-Powered-By: PHP/8.2.12.
  4. Scroll to All response headers and look for the x-powered-by line. Header names are shown in lower case.

Note that the check flags X-Powered-By even when it has no version number, such as plain Next.js. It flags the Server header only when it contains a number. Also look in the same list for x-aspnet-version, x-aspnetmvc-version and x-generator, which the tool treats as leaks too.

Behind Cloudflare, the server header normally reads cloudflare, with no version. That is not flagged. Cloudflare's own documentation says the value of the server header cannot be changed, so there is nothing to do there.

Method 1: the managed transform

Cloudflare has a ready-made option for exactly this. In its list of Managed Transforms there is a response-header transform named "Remove "X-Powered-By" headers", which removes the header from your responses.

  1. Log in to the Cloudflare dashboard and choose your domain.
  2. Open the Rules section and look for Managed Transforms. Menu names change from time to time, so search the dashboard for "Managed Transforms" if you cannot see it.
  3. Switch on "Remove "X-Powered-By" headers".

This is the quickest way for most sites, and it covers every hostname on the zone that is proxied through Cloudflare.

Method 2: a Modify Response Header rule

Use a rule when you want more control, for example only on one hostname, or to remove other headers as well.

  1. In the dashboard open Rules, then Transform Rules, then Modify Response Header.
  2. Create a rule and give it a name such as "Remove X-Powered-By".
  3. Choose which requests it applies to: all incoming requests, or a custom expression such as one hostname.
  4. Under Modify header, choose the Remove operation and type the header name, X-Powered-By.
  5. Deploy the rule.

Cloudflare's documentation lists Set static, Set dynamic, Add static, Add dynamic and Remove as the operations. Our scan tool's generated Cloudflare note points to the same place (Rules, Transform Rules, Modify Response Header) and says to use Set static to add headers and Remove to delete them, so for a removal choose Remove, not Set.

If the scan flagged more than one header, add one Remove rule per header name, for example X-AspNet-Version or X-Generator. Cloudflare does not allow changes to headers beginning with cf- or x-cf-, but that does not affect these.

Method 3: fix it at the origin

Removing it at the edge hides it from visitors who come through Cloudflare. If the header is never sent in the first place, it is gone everywhere. The right switch depends on your stack:

Stack How to stop sending the header
Next.js Set poweredByHeader: false in next.config.js
PHP Set expose_php = Off in php.ini and restart PHP
Nginx with PHP-FPM Add fastcgi_hide_header X-Powered-By;
Nginx as a proxy Add proxy_hide_header X-Powered-By;
Apache Add Header always unset X-Powered-By (needs mod_headers)
Express (Node) Call app.disable('x-powered-by')

The Security Headers Checker's Recommended headers panel writes some of these for you. Choose your Server platform, and set Which headers to Missing & weak. When a leak is found, the Nginx, Apache and Cloudflare output includes a removal line for each leaking header it found, such as X-AspNet-Version or X-Generator, not only X-Powered-By. The Next.js output turns off its own X-Powered-By and adds a comment for any other header, because Next.js does not send those itself; remove them at the server or proxy that adds them.

On Cloudflare Pages or Workers static assets, the generated output is a _headers file with a line ! X-Powered-By. Cloudflare's documentation says the ! detach only removes headers that earlier rules in the same file added, and that _headers does not apply to responses from Pages Functions. So if a header comes from your own Function code, remove it in the code.

Prove it worked

  1. Wait a minute, then scan again with the Security Headers Checker.
  2. The "Server / X-Powered-By" row should now say "No version leak" with 5 of 5 points.
  3. In All response headers, x-powered-by should be gone.
  4. For a second opinion on the raw headers, the HTTP Header Checker lists the same set with caching and timing details.

The scan always goes through redirects to the final page, so make sure you enter the address visitors really use. A scan of example.com that redirects to www.example.com reads the headers of the www page.

If it is still there

  • The record is DNS only. A grey cloud in Cloudflare's DNS list means traffic goes straight to your server and no Cloudflare rule runs. Look at the server header in All response headers: if it does not say cloudflare, the response did not pass through Cloudflare. Switch the record to proxied, or fix the origin.
  • The rule does not match. If the rule is limited to one hostname, check that you scanned that hostname, and both the www and non-www forms.
  • Another layer adds it. A load balancer, a second CDN or an application behind a reverse proxy may add the header after your origin. Remove it at the layer that sets it.
  • An old cached copy. Purge the cache for the address once and scan again.
  • You tested a page that is not served by your main site, such as a subdomain on a different host.

If the page will not load at all after your change, a status such as 521 or 522 is a connection problem, not a header problem. Those are explained in Cloudflare errors 520, 521 and 522.

Do not stop at one header

Removing X-Powered-By is a small win. The same scan will usually show bigger gaps: a missing Content-Security-Policy, a weak Strict-Transport-Security or cookies without flags. The complete Security Headers Checker guide shows how to work through them in order of points.

Quick checklist

  • Scan first and note which leak headers appear.
  • Turn on the managed transform, or add a Remove rule per header.
  • Also stop the header at the origin.
  • Scan again and confirm "No version leak".
  • Remember that the server value is Cloudflare's, and fine as it is.

Frequently asked questions

Is removing X-Powered-By a real security fix?
It is hygiene, not protection. It stops the site announcing its software, so automated scanners learn less, but it does not fix any vulnerability. Keep the software updated and treat the header as a small extra step.
Can Cloudflare hide the Server header too?
Cloudflare's documentation lists the server header among those whose value cannot be changed. On a proxied site it shows a Cloudflare value rather than your origin's software and version, so the version leak check normally has nothing to flag.
Why is X-Powered-By still there after I created the rule?
The usual reasons are that the record is DNS only (grey cloud) so traffic never passes through Cloudflare, the rule's expression does not match the hostname you scanned, or you scanned www while the rule covers the bare domain.
Should I also fix it at the origin?
Yes. Switching the header off in PHP, Next.js, Apache or Nginx means it is never sent, even if someone reaches the server without going through Cloudflare.
Do I need to purge the cache after adding the rule?
Scan again after a minute first. If the old header still appears, purge the cache for that address once and check again, in case an old copy was stored before the rule existed.
Found this useful? Share it

Tools in this guide

Main tool

Security Headers Checker

Find out which HTTP security headers a site sends, how strong they are and exactly what to add.

Open tool

HTTP Header Checker

See the exact status code and response headers a URL returns, follow its redirects, and get a security-header grade with clear fixes.

Open tool

SSL Checker

Test a site's SSL/TLS certificate in seconds: see when it expires, whether browsers trust it, if it matches the domain,.

Open tool

Redirect Checker

Follow a URL hop by hop and see every redirect's status code, destination, server and timing — plus clear advice on chains, loops.

Open tool

Back to all guides & blog