计算机知识分享网

【nginx】docker中的Nginx隐藏Nginx版本号

修改映射的nginx.cnf配置文件,在http模块中添加 server_tokens off,最后重启Nginx即可
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    server_tokens off;

#Nginx