nginx安装之后添加SSL站点及常用模块介绍

nginx安装成功之后,用到https的时候,发现安装的时候没有添加http_ssl_module。执行代码如下:

./configure --prefix=/usr/local/nginx --with-http_stub_status_module  --with-http_ssl_module  

报错:
./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.

解决方式:

yum -y install openssl openssl-devel  

安装成功之后,重新执行上面的配置。然后执行make,把objs中新生产的nginx替换sbin中旧的nginx。这个时候执行nginx -s reload,没有起作用。干掉nginx,重新启动就OK了。



nginx.conf配置如下:

server {
        listen       443 ;
        server_name  xx.xxx.com;
        ssl on;
        ssl_certificate sslkey/xx.xx.com.crt;  #证书文件路径
        ssl_certificate_key sslkey/xx.xx.com.key;  #秘钥文件路径
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
        ssl_prefer_server_ciphers on;
        location / {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_ignore_headers Set-Cookie Cache-Control;
            proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
            proxy_max_temp_file_size 0;
            proxy_connect_timeout 60;
            proxy_send_timeout 60;
            proxy_read_timeout 60;
            proxy_buffer_size 4k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
            proxy_cookie_path  / /dev/shm;
            proxy_pass    http://127.0.0.1:8080;
        }
  }



nginx编译参数说明如下:

操作说明
–prefix= < path >安装路径,如果没有指定,默认为/usr/local/nginx。
–sbin-path= < path >nginx可执行命令的文件,如果没有指定,默认为< prefix >/sbin/nginx。
–conf-path=< path >在没有使用-c参数指定的情况下nginx.conf的默认位置,如果没有指定,默认为< prefix >/conf/nginx.conf。
–pid-path=< path >nginx.pid的路径,如果没有在nginx.conf中通过“pid”指令指定,默认为< prefix >/logs/nginx.pid。
–lock-path=< path >nginx.lock文件路径,如果没有指定,默认为< prefix >/logs/nginx.lock。
–error-log-path=< path >当没有在nginx.conf中使用“error_log”指令指定时的错误日志位置,如果没有指定,默认为< prefix >/logs/error.log。
–http-log-path=< path >当没有在nginx.conf中使用“access_log”指令指定时的访问日志位置,如果没有指定,默认为< prefix >/logs/access.log。
–user=< user >当没有在nginx.conf中使用“user”指令指定时nginx运行的用户,如果没有指定,默认为“nobody”。
–group=< group >– 当没有在nginx.conf中使用“user”指令指定时nginx运行的组,如果没有指定,默认为“nobody”。
–builddir=DIR设置构建目录。
–with-rtsig_module启用rtsig模块。
–with-select_module
–without-select_module
如果在configure的时候没有发现kqueue, epoll, rtsig或/dev/poll其中之一,select模块始终为启用状态。
–with-poll_module
–without-poll_module
如果在configure的时候没有发现kqueue, epoll, rtsig或/dev/poll其中之一,poll模块始终为启用状态。
–with-http_ssl_module启用ngx_http_ssl_module,启用SSL支持并且能够处理HTTPS请求。需要OpenSSL,在Debian系统中,对应的包为libssl-dev。
–with-http_realip_module启用ngx_http_realip_module
–with-http_addition_module启用ngx_http_addition_module
–with-http_sub_module启用ngx_http_sub_module
–with-http_dav_module启用ngx_http_dav_module
–with-http_flv_module启用ngx_http_flv_module
–with-http_stub_status_module启用”server status”(服务状态)页
–without-http_charset_module禁用ngx_http_charset_module
–without-http_gzip_module禁用ngx_http_gzip_module,如果启用,需要zlib包。
–without-http_ssi_module禁用ngx_http_ssi_module
–without-http_userid_module禁用ngx_http_userid_module
–without-http_access_module禁用ngx_http_access_module
–without-http_auth_basic_module禁用ngx_http_auth_basic_module
–without-http_autoindex_module禁用ngx_http_autoindex_module
–without-http_geo_module禁用ngx_http_geo_module
–without-http_map_module禁用ngx_http_map_module
–without-http_referer_module禁用ngx_http_referer_module
–without-http_rewrite_module禁用ngx_http_rewrite_module。如果启用,需要PCRE包。
–without-http_proxy_module禁用ngx_http_proxy_module
–without-http_fastcgi_module禁用ngx_http_fastcgi_module
–without-http_memcached_module禁用ngx_http_memcached_module
–without-http_limit_zone_module禁用ngx_http_limit_zone_module
–without-http_empty_gif_module禁用ngx_http_empty_gif_module
–without-http_browser_module禁用ngx_http_browser_module
–without-http_upstream_ip_hash_module禁用ngx_http_upstream_ip_hash_module
–with-http_perl_module启用ngx_http_perl_module
–with-perl_modules_path=PATH为perl模块设置路径
–with-perl=PATH为perl库设置路径
–http-client-body-temp-path=PATH为http连接的请求实体临时文件设置路径,如果没有指定,默认为< prefix >/client_body_temp
–http-proxy-temp-path=PATH为http代理临时文件设置路径,如果没有指定,默认为< prefix >/proxy_temp
–http-fastcgi-temp-path=PATH为http fastcgi临时文件设置路径,如果没有指定,默认为< prefix >/fastcgi_temp
–without-http禁用HTTP服务
–with-mail启用IMAP4/POP3/SMTP代理模块
–with-mail_ssl_module启用ngx_mail_ssl_module
–with-cc=PATH设置C编译器路径
–with-cpp=PATH设置C预处理器路径
–with-cc-opt=OPTIONS变量CFLAGS中附加的参数,用于FreeBSD中的PCRE库,同样需要指定–with-cc-opt=”-I /usr/local/include”,如果我们使用select()函数则需要同时增加文件描述符数量,可以通过–with-cc-opt=”-D FD_SETSIZE=2048”指定。
–with-ld-opt=OPTIONS通过连接器的附加参数,用于FreeBSD中的PCRE库,同样需要指定–with-ld-opt=”-L /usr/local/lib”。
–with-cpu-opt=CPU指定编译的CPU,可用的值为: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64
–without-pcre禁用PCRE库文件,同时将禁用HTTP rewrite 模块,如果要在”location”指令中使用正则表达式,同样需要PCRE库。
–with-pcre=DIR设置PCRE库源文件路径。
–with-pcre-opt=OPTIONS在编译时为PCRE设置附加参数。
–with-md5=DIR设置md5库源文件路径。
–with-md5-opt=OPTIONS在编译时为md5设置附加参数。
–with-md5-asm使用md5汇编源。
–with-sha1=DIR设置sha1库源文件路径。
–with-sha1-opt=OPTIONS在编译时为sha1设置附加参数。
–with-sha1-asm使用sha1汇编源。
–with-zlib=DIR设置zlib库源文件路径。
–with-zlib-opt=OPTIONS在编译时为zlib设置附加参数。
–with-zlib-asm=CPU为指定的CPU使用zlib汇编源进行优化,可用值为: pentium, pentiumpro。
–with-openssl=DIR设置openssl库源文件路径。
–with-openssl-opt=OPTIONS在编译时为openssl设置附加参数。
–with-debug启用debug记录。
–add-module=PATH增加一个在PATH中的第三方模块。
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值