{"id":1279,"date":"2017-03-24T17:05:49","date_gmt":"2017-03-24T11:35:49","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=1279"},"modified":"2017-03-24T17:05:49","modified_gmt":"2017-03-24T11:35:49","slug":"hide-webserver-informationmodify-server-header-nginx","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/hide-webserver-informationmodify-server-header-nginx\/","title":{"rendered":"Hide Webserver information|Modify Server Header on Nginx"},"content":{"rendered":"<p><strong>Date Posted:24\/03\/2017<\/strong><\/p>\n<p>By default, webserver version, OS information will be visible to public which consider as a security problem because its not a good practice to expose server information. This may result in hackers to intrude your server incase if any vulnerability. So, its always good to hide all server information.<\/p>\n<h4>Assumption:<\/h4>\n<ol>\n<li>Ubuntu or Centos Host<\/li>\n<li>Nginx Webserver<\/li>\n<\/ol>\n<p>Incase if nginx is not installed, follow the below post depends on your server environment.<\/p>\n<ul>\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/install-nginx-php-mariadb-ubuntu-16-04-1\/\">Install Nginx on Ubuntu<\/a><\/li>\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/install-nginx-php-fpm-mariadb-on-centos-7\/\">Install Nginx on\u00a0Centos 7<\/a><\/li>\n<\/ul>\n<h4>Implementation:<\/h4>\n<p>We have may to install nginx-extras on ubuntu host. This post only tested with Ubuntu host. We never tried this on centos host. You can still follow this post to achieve the same.<\/p>\n<p><code>apt-get -y install nginx-extras<\/code><\/p>\n<p>Before implementing, let&#8217;s test whether the server information is exposing to the public. Open a terminal and execute the below command.<\/p>\n<p><code>curl -I\u00a0http:\/\/IPaddress<\/code><\/p>\n<p>The output will be displayed as below,<\/p>\n<blockquote><p>HTTP\/1.1 301 Moved Permanently<br \/>\nServer: nginx\/<span style=\"color: #ff0000;\">1.10.0 (Ubuntu)<\/span><\/p><\/blockquote>\n<p>Open the nginx.conf configuration. Under\u00a0<em>http\u00a0<\/em>section, identify and update\/add\/modify the below line<\/p>\n<p><code>vi \/etc\/nginx\/nginx.conf<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">server_tokens off; \r\nmore_set_headers 'Server: PheonixSolutions'<\/pre>\n<p>Where,<\/p>\n<p><em>server_tokens off<\/em> will hide Os Information<\/p>\n<p><em>more_set_headers <\/em>sets<em>\u00a0<\/em>user specified information.<\/p>\n<p>Verify whether any syntax error on the configuration.<\/p>\n<p><code>nginx -t<\/code><\/p>\n<p>Restart nginx service.<\/p>\n<p><code>service nginx restart<\/code><\/p>\n<h5>Verification:<\/h5>\n<p>Execute the same curl command and see whether we are getting the same information.<\/p>\n<p><code>curl http:\/\/IPaddress<\/code><\/p>\n<blockquote><p>HTTP\/1.1 301 Moved Permanently<\/p>\n<p>Server: \u00a0<span style=\"color: #ff0000;\">PheonixSolutions<\/span><\/p><\/blockquote>\n<p>From above result, we can see OS information hided and Web Server information also modified.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Date Posted:24\/03\/2017 By default, webserver version, OS information will be visible to public which consider as a security problem because [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[271,307,159],"class_list":["post-1279","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-nginx","tag-security","tag-webserver","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-kD","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=1279"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1279\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}