In certain scenarios, you might want to remove the server information from your request header.
Therefore, we might consider hiding that information. In Azure App Service for PHP, we are using Nginx, and we can modify configuration files if necessary.
First, we need to locate the Nginx configuration file on the Kudu site, which can be found at the path /etc/nginx/nginx.conf.
Then, perform cp /etc/nginx/nginx.conf /home/site/nginx.conf.
We modify the configuration file under /home to retain our changes. We open the configuration file and uncomment the server_tokens off; directive in the http section of the Nginx configuration.
Then you need to configure the startup command using Azure Portal from Configuration -> General Settings as below:
cp /home/nginx.conf /etc/nginx/nginx.conf &&
service nginx reload
Checking again, we can see that the Nginx version is hidden.
But what if we want to hide all the server information?
To do this, follow these steps:
(1) Copy the Nginx configuration file to the /home directory as we mentioned earlier. This is necessary because any files outside of /home will not be preserved after a restart. Use the following command:
cp /etc/nginx/nginx.conf /home/site/nginx.conf
(2) Open the Nginx configuration file located in /home, and add the following line in the http section.
more_clear_headers 'server'.
After adding it, save the file.
(3) Update custom startup command using Azure Portal from Configuration -> General Settings as follows:
apt update &&
apt install -y nginx-extras &&
cp /home/nginx.conf /etc/nginx/nginx.conf &&
service nginx reload
(4) Once done, and the request header should no longer display the Server information.
Reference: How to set Nginx headers -