Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Server Header from Nginx #155

Closed
nazari-ali opened this issue Dec 7, 2022 · 7 comments
Closed

Remove Server Header from Nginx #155

nazari-ali opened this issue Dec 7, 2022 · 7 comments

Comments

@nazari-ali
Copy link

Hi

How can I delete the server header for nginx?
Thankful

@JonasAlfredsson
Copy link
Owner

Hi nazari-ali,

Is this the same question as #104 or are you asking for something differently?

@nazari-ali
Copy link
Author

nazari-ali commented Dec 8, 2022

Hi,
Thank you for responding

I want the server name to be completely removed, I use the "server_tokens off;" command in my attachment file I can only remove the Nginx version.

I used the links below to remove the Nginx name, but I ran into problems every time.

Answer 1
https://www.cyberciti.biz/faq/hide-nginx-version-in-linux-and-unix/
image

Answer 2
https://itecnotes.com/server/linux-how-to-disable-server-and-server-tokens-header-parameters-on-nginx/
image

Answer 3
https://www.appsloveworld.com/docker/100/27/how-can-i-remove-server-header-in-nginx-docker-container
image

@JonasAlfredsson
Copy link
Owner

So you want to remove the "Server: Someting" that is transmitted in the request.
And option 1 does not work on the Nginx version this image is based on?

Option 2 is one alternative if you are felling adventurous, you could probably look at the parent containers build scripts.
Option 3 will not work in with the parent Image we are based on, see #154 for further discussion.

I have not looked into this particular setting as I have never thought about turning it off, so I don't really have a lot of input to this issue, sorry :/

@nazari-ali
Copy link
Author

For Option 2, can you guide me on what to do?

@JonasAlfredsson
Copy link
Owner

I would start at looking at the parent container's Dockerfile, and then see where in those steps the guide you linked would fit in.

However, recompiling Nginx is not really anything I have done, but I think there is a guide on the Nginx official page you can look at.

@nazari-ali
Copy link
Author

nazari-ali commented Dec 9, 2022

Hi,

This worked for me without any problems.

sed -i 's/Server: nginx/My-Header: hi/' which nginx

Answer: https://stackoverflow.com/questions/246227/how-do-you-change-the-server-header-returned-by-nginx
image

@JonasAlfredsson
Copy link
Owner

Cool! Great find!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants