• 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 , change name nginx , nginx add servername to header , mofify server header nginx , change NGINX server name , change nginx headername , X-Frame-Options

This Article Has Been Shared 629 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Orthopaedic 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

You can subscribe to our Free Once a Day, Regular Newsletter by clicking the subscribe button below.

Click To Subscribe

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 (21K Followers)
  • Twitter (5.3k 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

  • How Startups Can Convince the Investors April 14, 2021
  • What to Know About the Cloud Storage Services for Smartphones April 13, 2021
  • WonderFox HD Video Converter Factory Pro Review April 10, 2021
  • What is the Maximum Cable Length Between Arduino/ESP32 and a Sensor April 8, 2021
  • Is the Blockchain Hype Running Out of Breath? April 7, 2021

 

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, April 15, 2021, https://thecustomizewindows.com/2015/04/change-nginx-server-name-in-header-on-ubuntu-server/.

Source:The Customize Windows, JiMA.in

 

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Cookie Policy.

PC users can consult Corrine Chorney for Security.

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

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

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