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

版权声明:本文为博主原创文章,转载请注明出处。如有错误,欢迎大家批评指正。 https://blog.csdn.net/a_bang/article/details/70748023

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中的第三方模块。

猜你喜欢

转载自blog.csdn.net/a_bang/article/details/70748023