美文网首页
Nginx 添加第三方模块编译安装

Nginx 添加第三方模块编译安装

作者: 无敌闹闹 | 来源:发表于2019-02-22 01:43 被阅读0次

起因

  笔者最近搭建了一个12306验证码识别网站,但是发现返回Headers的信息特别多,这样会涉及到服务器的安全问题,于是笔者想屏蔽掉一些Response Headers。Nginx屏蔽Headers需要添加第三方模块,由于笔者当时直接apt install nginx,所以需要重新编译安装。故记录于此。

准备工具

开始

下载Nginx源码

wget http://nginx.org/download/nginx-1.15.8.tar.gz
tar zxvf nginx-1.15.8.tar.gz
cd nginx-1.15.8

下载headers-more-nginx-module

wget https://github.com/openresty/headers-more-nginx-module/archive/v0.33.tar.gz
tar xzvf v0.33.tar.gz

如果已经安装Nginx请先卸载

apt remove nginx-mod*

配置参数

./configure --add-module=./headers-more-nginx-module-0.33/ --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid  --prefix=/usr --modules-path=/usr/lib/nginx/modules/

然后报错

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

提示需要依赖 PCRE library 模块

apt-get install libpcre3-dev

继续报错

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

提示需要依赖 OpenSSL 模块

apt-get install libssl-dev

编译and安装

make install

通过配置 Server

Server {
    ...
    #清除 X-Powered-By
    more_clear_headers "X-Powered-By:";
    #设置 Server
    more_set_headers    "Server: Naonao High Performance Web Server V1.0";
    ...
}

然后重启Nginx
Good luck~


Response Headers

相关文章

  • nginx 编译安装

    1、nginx安装 1.1、下载包 1.2、解压编译 1.3、启动 2、已安装nginx编译添加模块 2.1、查看...

  • centos7 使用nginx上传文件

    安装nginx以及nginx-upload-module模块 下载nginx源码,添加模块只支持源码编译:wget...

  • Nginx篇01——基本安装配置和静态页面设置

    nginx的编译安装、添加模块、yum安装、简单配置、默认目录作用和静态页面配置。 0、编译安装nginx 0.1...

  • 已安装nginx动态添加模块

    说明:已经安装好的nginx,需要添加一个未被编译安装的模块,需要怎么弄呢? 具体:这里以安装第三方ngx_htt...

  • Centos 7 已安装nginx动态添加模块

    说明: 已经安装好的nginx,需要添加一个未被编译安装的模块,需要怎么弄呢? 具体: 这里以安装第三方ngx_h...

  • 已安装nginx动态添加模块

    说明:已经安装好的nginx,需要添加一个未被编译安装的模块,需要怎么弄呢? 具体:这里以安装第三方ngx_htt...

  • Nginx 配置 https

    准备工作 安装好 Nginx (注意编译安装 Nginx 时要把 SSL 模块添加上,否则不能配置 https,编...

  • Nginx编译安装

    一、简介 Nginx编译安装,应当是安装Nginx的最佳方式,因为这样可以通过第三方模块为Nginx增加许多强有力...

  • Nginx模块

    一、编译添加新模块 1.简介与思路 当前适用于nginx已经在安装过了,如果没安装过,直接在编译时候添加模块即可。...

  • Linux_258_Nginx状态页

    nginx提供了status模块,用于检测nginx的请求连接信息,这个功能需要在编译安装nginx的时候,添加-...

网友评论

      本文标题:Nginx 添加第三方模块编译安装

      本文链接:https://www.haomeiwen.com/subject/brajyqtx.html