nginx安裝http_ssl_module模組,支援https
阿新 • • 發佈:2018-12-24
1,進入原始碼包,如:
cd /usr/local/nginx-1.15.0/
2,執行nginx -V命令檢視已經安裝的nginx模組(configure arguments:後面表示當前已經安裝的nginx模組)如:
[[email protected] ~]# /usr/local/nginx/sbin/nginx -V nginx version: nginx/1.15.0 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module
3,配置nginx引數,加上之前nginx已經安裝的模組和http_ssl_module模組,如:
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
4,編譯
make
5,備份原有已安裝好的nginx
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
6,然後將剛剛編譯好的nginx覆蓋掉原有的nginx(這個時候nginx要停止狀態)
cp ./objs/nginx /usr/local/nginx/sbin/
7,檢視安裝結果:
[[email protected] ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.15.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
8,一個簡單的ssl配置demo(同時支援http和https請求)
server {
listen 80;
listen 443 ssl;
#圖片路徑攔截,定位到圖片靜態資源
location ~ /uploads/.*$ {
root /www/;
expires 30d;
}
#docker環境配置----------------------------------------
#admin test測試環境
location ^~ /blockchain_admin_test/ {
proxy_pass http://localhost:7112/;
}
#api test測試環境
location ^~ /blockchain_api_test/ {
proxy_pass http://localhost:7012/;
}
ssl_certificate /usr/local/nginx/conf/ssl/cx.blockchain.hyonline.online.pem;
ssl_certificate_key /usr/local/nginx/conf/ssl/cx.blockchain.hyonline.online.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}