How to remove the X-Powered-By header?

Created:

2017-06-27 09:52:58 UTC

Modified:

2017-08-23 10:21:39 UTC

1

Was this article helpful?


Have more questions?

Submit a request

How to remove the X-Powered-By header?

Question

How to remove the X-Powered-By header?

# curl -I https://example.com 
HTTP/1.1 200 OK 
Server: nginx 
Date: Tue, 27 Jun 2017 07:35:01 GMT 
Content-Type: text/html; charset=UTF-8 
Connection: keep-alive 
Vary: Accept-Encoding 
Last-Modified: Tue, 27 Jun 2017 07:17:00 GMT 
Accept-Ranges: bytes 
Expires: Mon, 30 Oct 1923 20:30:00 GMT 
Cache-Control: max-age=0, no-cache, no-store, must-revalidate 
Pragma: no-cache 
X-Powered-By: PleskLin

Answer

The header X-Powered-By is specified in the following files:

# grep -ir X-Powered-By /usr/local/psa/admin/conf/templates/default
/usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php: add_header X-Powered-By PleskLin;
/usr/local/psa/admin/conf/templates/default/domain/nginxForwarding.php: add_header X-Powered-By PleskLin;
/usr/local/psa/admin/conf/templates/default/server.php: Header add X-Powered-By PleskLin

The solution is to create custom templates and modify them:

  1. Create a directory for custom templates:

    # mkdir -p /usr/local/psa/admin/conf/templates/custom/domain
  2. Copy default templates to custom directories:

    # cp /usr/local/psa/admin/conf/templates/default/server.php /usr/local/psa/admin/conf/templates/custom
    # cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain
    # cp /usr/local/psa/admin/conf/templates/default/domain/nginxForwarding.php /usr/local/psa/admin/conf/templates/custom/domain
  3. Open the file /usr/local/psa/admin/conf/templates/custom/server.php and remove the following content:

    <?php if (!$VAR->server->webserver->proxyActive): ?>
    <IfModule mod_headers.c>
    Header add X-Powered-By PleskLin
    </IfModule>
    <?php endif ?>
  4. From the file /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php remove the following content:

    <?php foreach ((array)$VAR->domain->physicalHosting->headers as list($name, $value)): ?>
    add_header <?=$VAR->quote([$name, $value])?>;
    <?php endforeach ?>
    add_header X-Powered-By PleskLin;
  5. From the file /usr/local/psa/admin/conf/templates/custom/domain/nginxForwarding.php remove the following content:

    add_header X-Powered-By PleskLin;
  6. Reconfigure configuration files:

    # /usr/local/psa/admin/sbin/httpdmng --reconfigure-all
  7. Check the result.

Have more questions? Submit a request
Please sign in to leave a comment.