1.修改src/http/ngx_http_header_filter_module.c
2.修改src/core/nginx.h
3.修改src/http/ngx_http_special_response.c
wget -c https://github.com/openresty/headers-more-nginx-module/archive/refs/tags/v0.34.tar.gz
sudo su (需要切换到root用户)
export LUAJIT_LIB=/usr/local/lib/
export LUAJIT_INC=/usr/local/include/luajit-2.1/
export LD_LIBRARY_PATH=$LUAJIT_LIB
./configure --user=www --group=www --prefix=/www/server/nginx --add-module=/www/server/nginx/src/ngx_devel_kit --add-module=/www/server/nginx/src/lua_nginx_module --add-module=/www/server/nginx/src/ngx_cache_purge --with-openssl=/www/server/nginx/src/openssl --with-pcre=pcre-8.43 --with-http_v2_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_stub_status_module --with-http_ssl_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --add-module=/www/server/nginx/src/ngx_http_substitutions_filter_module-master --with-ld-opt=-Wl,-E --with-cc-opt=-Wno-error --with-ld-opt=-ljemalloc --with-http_dav_module --add-module=/www/server/nginx/src/nginx-dav-ext-module --add-module=/www/server/nginx/src/headers-more-nginx-module
make
# 备份原本的Nginx文件
mv /www/server/nginx/sbin/nginx{,.bak}
#cp objs/nginx /www/server/nginx/sbin
make install
nginx -s reload
确认配置是否正确:
相关文档:
header
比如隐藏Server字段:或者写上Server: xxx
对应前端: