1. 安裝****SSL模塊
要在nginx中配置https,就必須安裝ssl模塊,也就是: http_ssl_module 。
進(jìn)入到nginx的解壓目錄: /home/software/nginx-1.16.1
新增ssl模塊(原來(lái)的那些模塊需要保留)
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--with-http_ssl_module
編譯和安裝
make
make install
2. 配置HTTPS
把ssl證書 *.crt 和 私鑰 *.key 拷貝到 /usr/local/nginx/conf 目錄中。
新增server 監(jiān)聽443 端口:
server {
listen 443;
server_name www.imoocdsp.com;
開啟ssl
ssl on;
配置ssl證書
ssl_certificate 1_www.imoocdsp.com_bundle.crt;
配置證書秘鑰
ssl_certificate_key 2_www.imoocdsp.com.key;
ssl會(huì)話cache
ssl_session_cache shared:SSL:1m;
ssl會(huì)話超時(shí)時(shí)間
ssl_session_timeout 5m;
配置加密套件碍彭,寫法遵循 openssl 標(biāo)準(zhǔn)
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
proxy_pass <u>http://tomcats/;</u>
}