Close Menu
    Facebook X (Twitter) Instagram
    • Download Cisco Packet Tracer
    Facebook X (Twitter) Instagram Pinterest Vimeo
    IT Beginner
    • Home
    • Server
    • WordPress
    IT Beginner
    Home»Security»How to remove PHP X-Powered-By & Nginx Version
    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
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    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
    Tags
    apache centos Centos 6 cuda Desktop Environment dual boot environment featured gnome GUI hostname hosts intel kernel kill lamp server lemp server life MariaDB netflix nginx nvidia password php-fpm phpmyadmin pids processes s.m.a.r.t Security session solid state drive ssd ssh ssh server tag 1 tag 2 Ubuntu upgrade varnish VirtualBox VNC Server web server window manager wordpress xfce
    Facebook X (Twitter) Instagram Pinterest

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

    wpDiscuz