docker build . -t nginx-no-server-header
docker container run --rm -p 3333:80 nginx-no-server-header
# then
curl localhost:3333/
curl localhost:3333/ -I
Created
March 13, 2025 21:36
-
-
Save jdthorpe/4b106ea79a7d0373560d95637d2fa330 to your computer and use it in GitHub Desktop.
Nginx in Docker without the `Server` header (via nginx-extras)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian | |
RUN apt-get update \ | |
&& apt-get install -y nginx nginx-extras | |
COPY ./index.html /www/data/index.html | |
COPY ./nginx.conf /etc/nginx/nginx.conf | |
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello nginx + nginx-extras</title> | |
<meta charset="utf-8" /> | |
</head> | |
<body> | |
<h1>Hey look I don' thave a <pre>Server</pre> header</h1> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load_module modules/ngx_http_headers_more_filter_module.so; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
server { | |
more_clear_headers Server; | |
listen 80; | |
location / { | |
root /www/data; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment