Close Menu
    Facebook X (Twitter) Instagram
    • Articles
    • How it Works
    • Our Story
    • Contact Us
    Facebook X (Twitter) Instagram Pinterest Vimeo
    IT Beginner
    • Home
    • Blog
      • Happiness
      • Productivity
      • Leadership
    • About us
    • Contact us
    IT Beginner
    Security

    How to remove PHP X-Powered-By & Nginx Version

    25/07/2017Updated:25/07/2017No Comments2 Mins Read

    While I’m auditing my website’s security with curl command to view HTTP Response Header. I see that nginx gives out quite some server’s info which should be hidden for security reason.

    You can view your HTTP Response Header with curl command

    $ curl -I http://domain.com/

    This is the output from one of my Nginx web server

    HTTP/1.1 200 OK
    
    Server: nginx/1.6.0
    
    Date: Fri, 09 May 2014 05:19:45 GMT
    
    Content-Type: text/html; charset=UTF-8
    
    Connection: keep-alive
    
    X-Powered-By: PHP/5.5.12

    Those information is available to the public if someone want to view it. I’m going to show you how to hide Nginx’s version and X-Powered-By (PHP’s version)

    To remove X-Powered-By (PHP’s version)

    Generally PHP’s configuration file ( php.ini ) should be located in /etc/ directory, to remove X-Powered-By you have to edit php.ini file

    # nano /etc/php.ini

    Search for expose_php, by default expose_php is On to display PHP version within the HTTP header.

    expose_php = On

    To remove X-Powered-By, turn expose_php off

    expose_php = Off

    Save php.ini file and restart Apache or php-fpm whatever you are running.
    To restart Apache on CentOS/RedHat/Fedora

    # service httpd restart

    To restart Apache on Debian/Ubuntu/Linux Mint

    # service apache2 restart

    To restart php-fpm if you are running php-fpm with Nginx

    # service php-fpm restart

    To remove Nginx Version

    Nginx will give out its version in HTTP response header and nginx default error pages. For security reason we will also need to hide Nginx version. To hide Nginx version, we need to change server_tokens parameter from on (it’s on by default) to off in Nginx configuration file.

    # nano /etc/nginx/nginx.conf

    and add server_tokens off; inside http { your nginx configurations here }.

    http {
    
    server_tokens off;
    
    }
    You must restart Nginx to take affect
    # service nginx restart
    Now check HTTP response header with curl command again, PHP X-Powered-By and Nginx version should be removed.
    $ curl -I http://domain.com/
    and its output
    HTTP/1.1 200 OK
    
    Server: nginx
    
    Date: Fri, 09 May 2014 05:53:47 GMT
    
    Content-Type: text/html; charset=UTF-8
    
    Connection: keep-alive
    expose_php server_tokens
    Previous ArticleRemove WordPress X-Pingback header
    Next Article How to fix GPG error NO_PUBKEY in Ubuntu

    Related Posts

    Security

    How to secure Nginx web server

    02/08/2017
    Security

    How to secure Apache HTTP Web Server

    29/07/2017
    CentOS

    How to install fail2ban on CentOS 6 and 7

    29/07/2017
    Subscribe
    Notify of
    guest

    guest

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    0 Comments
    Oldest
    Newest Most Voted
    Inline Feedbacks
    View all comments
    • Productivity
    • Leadership

    No posts

    No posts

    Subscribe to Newsletter
    Our Socials
    • Instagram
    • Facebook
    • Twitter
    • YouTube
    • LinkedIn

    Archives

    • April 2025
    • May 2024
    • March 2023
    • July 2022
    • March 2022
    • July 2020
    • January 2019
    • August 2018
    • July 2018
    • August 2017
    • July 2017
    • September 2016

    Categories

    • Business
    • CCNA 1 Instructor Materials
    • CentOS
    • Database
    • Debian
    • Fedora
    • Firefox
    • Happiness
    • Hardware
    • ICND1 Labs
    • ICND2 Labs
    • Leadership
    • Linux Essentials
    • Linux Mint
    • Marketing
    • My SQL
    • Netflix
    • Networking
    • Productivity
    • Resources
    • Security
    • SEO
    • Server
    • Social Media
    • Software
    • Tips – Tricks
    • Ubuntu
    • Uncategorized
    • User Experience
    • WordPress
    • Xubuntu

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna accumsan in scelerisque.

    Facebook X (Twitter) Instagram Pinterest

    Type above and press Enter to search. Press Esc to cancel.

    wpDiscuz