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中的第三方模塊。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章