• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Change Nginx Server Name in Header on Ubuntu Server

By Abhishek Ghosh April 19, 2015 3:37 am Updated on April 19, 2015

Change Nginx Server Name in Header on Ubuntu Server

Advertisement

Declaring the Server Name is a Security Risk, You Can Change the Server Name From Nginx to Apache2 or What You Want. It is Easier on Ubuntu. For non-deb Linux distort, the only way to change is to compile from the source, which is pathetically bad and big work for many running instances. Debian/Ubuntu has some advantages. If you are using apt for OS X, you can use this trick to change Nginx server name. You can directly go to the Change Nginx Server Name in Header on Ubuntu Server With HttpHeadersMoreModule sub header if you are using Ubuntu. This conventional way is kept as legacy method.

 

Traditional Way to Change Nginx Server Name in Header on Ubuntu Server

 

If we run curl -I for our website, we will get this :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
âžœ  ~  curl -I https://thecustomizewindows.com
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 19 Apr 2015 02:58:32 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.5.9-1ubuntu4.7
Set-Cookie: PHPSESSID=57riuklgncj2ej0n936r2tq2g1; path=/
Expires: Sat, 13 Feb 2016 02:58:32 GMT
Cache-Control: max-age=25920000
Pragma: no-cache
X-Pingback: https://thecustomizewindows.com/xmlrpc.php
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Public-Key-Pins: pin-sha256="cTvjlwJ90gznKckrq+Le+9w5ncyKFwzLJOkgMBNoX2M="; max-age=5184000; includeSubDomains
Cache-Control: Public
Alternate-Protocol: 443:npn-spdy/3
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

We are talking about the third line – Server: nginx. X-Powered-By: PHP/5.5.9-1ubuntu4.7 is coming from PHP. This also shroud be changed, which is PHP related matter. Removing the version is very easy. You need to add :

Advertisement

---

Vim
1
server_tokens off;

in etc/nginx/nginx.conf file. For changing at compilation level, if you are building nginx kept at /src/nginx/, cd and open this file with nano :

Vim
1
2
cd /src/nginx/
nano src/http/ngx_http_header_filter_module.c

Find these two lines :

Vim
1
2
static char ngx_http_server_string[] = "Server: nginx" CRLF;
static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;

That nginx and NGINX_VER has to be changed.

Change Nginx Server Name in Header on Ubuntu Server

 

Change Nginx Server Name in Header on Ubuntu Server With HttpHeadersMoreModule

 

HttpHeadersMoreModule gives the way to use this directive :

Vim
1
2
3
4
5
6
7
8
9
# set the Server output header
    more_set_headers 'Server: Apache2';
# set and clear output headers
    location /bar {
        more_set_headers 'X-MyHeader: blah' 'X-MyHeader2: foo';
        more_set_headers -t 'text/plain text/css' 'Content-Type: text/foo';
        more_set_headers -s '400 404 500 503' -s 413 'Foo: Bar';
        more_clear_headers 'Content-Type';
    }

In official websites you will get lot of examples. We are talking about using only more_set_headers 'Server: Apache2'; part. Others are additional usage. nginx is available in three flavors – nginx-light, nginx-full, nginx-extras. The others are – nginx-core, nginx-naxsi etc. When we use apt-get install nginx, the medium thing is installed. If we use apt-get install nginx nginx-extras command, we will get this module without compilation. In deb wiki, you’ll get more details :

Vim
1
https://wiki.debian.org/Nginx # copy the url to plain text editor first

Do not run the apt-get install nginx nginx-extras command, without taking backup of the /etc/nginx/nginx.conf and config file your site, usually this – /etc/nginx/sites-available/default. If you are using OpenStack, then you can take a snapshot and work with the kind of dev instance. For HTTPS sites, actually you’ll have to work a lot only for adding the things. There is no informative info when we run the apt-get install nginx command, this creates the problem. Otherwise almost all would use the extras version, frankly; this is the right stuff for most commonly used setups.

Tagged With nginx change server name , server_name header , ngx header server , nginx server_name , nginx server name , change name nginx , nginx add servername to header , mofify server header nginx , change NGINX server name , change nginx headername

This Article Has Been Shared 895 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Change Nginx Server Name in Header on Ubuntu Server

  • Deploying a Facebook App With Heroku Cloud

    Deploying a Facebook App With Heroku enables to run your custom Application on Facebook. Its looks tough at first, but really not that difficult to work.

  • Install and Run Shadows Rising RPG Game on Rackspace Cloud Sites

    Install and Run Shadows Rising RPG Game on your own Rackspace Cloud Sites and with the power of Cloud Computing enjoy this browser based RPG written in PHP.

  • Juju on Rackspace Cloud Server : Test Drive with Ubuntu 12.04

    Juju on Rackspace Cloud Server is a test drive in real time. It is some what like driving a F1 car on a busy avenue for the first time in life. Start the Cloud. And the ride is too without wearing helmet – on an Operating System without any smartness – Windows 7 with PuTTY. […]

  • Cloud Computing and Ubuntu : Richard Stallman’s View

    Cloud Computing and Ubuntu both historically is being criticized by Richard Stallman not once but many a times. Why Father of Free Software Movement is against?

  • HP ASCII Logo on SSH Pre-Login (HP Cloud, Ubuntu)

    Here is How To Add Hewlett-Packard Company Official Logo on HP Helion Public Cloud on Ubuntu 14.04 LTS Instance. The HP Logo is an ASCII Art.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What is an Automatic Ethanol Fireplace February 8, 2023
  • Disadvantages of Cloud-Native Computing February 7, 2023
  • Projector Screen Basics February 6, 2023
  • What is Configuration Management February 5, 2023
  • What is ChatGPT? February 3, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Change Nginx Server Name in Header on Ubuntu Server," in The Customize Windows, April 19, 2015, February 8, 2023, https://thecustomizewindows.com/2015/04/change-nginx-server-name-in-header-on-ubuntu-server/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT