Skip to content

Instantly share code, notes, and snippets.

@jdthorpe
Created March 13, 2025 21:36
Show Gist options
  • Save jdthorpe/4b106ea79a7d0373560d95637d2fa330 to your computer and use it in GitHub Desktop.
Save jdthorpe/4b106ea79a7d0373560d95637d2fa330 to your computer and use it in GitHub Desktop.
Nginx in Docker without the `Server` header (via nginx-extras)
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;"]
<!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>

Usage

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
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