Nginx如果未開啓SSL模塊,配置Https時提示錯誤(the "ssl" parameter requires ngx_http_ssl_module)

Nginx如果未開啓SSL模塊,配置Https時提示錯誤

原因也很簡單,nginx缺少http_ssl_module模塊,編譯安裝的時候帶上–with-http_ssl_module配置就行了,但是現在的情況是我的nginx已經安裝過了,怎麼添加模塊???

操作如下:
說明:我的nginx的安裝目錄是/usr/local/nginx這個目錄(默認安裝目錄),我的源碼包在/home/local/dyxx/download/nginx-1.14.2目錄。

nginx: [emerg] the “ssl” parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:19

操作步驟
一步:切換到源碼包:cd /home/local/dyxx/download/nginx-1.14.2

二步:查看nginx原有的模塊 /usr/local/nginx/sbin/nginx -V
在configure arguments:後面顯示的原有的configure參數如下:
在這裏插入圖片描述
三步:那麼我們的新配置信息就應該這樣寫,運行下面的命令即可,等配置完。
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

四步:配置完成後,運行命令 make
特別注意】這裏不要進行make install,否則就是覆蓋安裝

五步:然後備份原有已安裝好的nginx
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

五步:然後將剛剛編譯好的nginx覆蓋掉原有的nginx(這個時候【特別注意】這裏nginx要停止狀態
cp ./objs/nginx /usr/local/nginx/sbin/

六步:然後啓動nginx,仍可以通過命令查看是否已經加入成功
/usr/local/nginx/sbin/nginx -V 
在這裏插入圖片描述
七步:最後啓動nginx
定位:cd /usr/local/nginx/sbin/
停止:./nginx -s quit
啓動:./nginx

Nginx 配置Http和Https共存

nginx.confhttps配置文件:

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
	#網站配置----開始
	server {
        server_name xxoo.net www.xxoo.net xxoo.cn www.xxoo.cn;#這裏可以配置多個域名已逗號空格我這裏配置了4個(即用戶可能輸入你公司相關域名)
		return 301 https://www.xxoo.com$request_uri;#這裏的www.xxoo.com就是你公司的域名和**注意0**相同
	}
    server {
		listen 80;
		listen 443 ssl;
		server_name www.xxoo.com;#**注意0**你的公司域名,最終瀏覽器地址欄看到的
		ssl_certificate   /home/local/xxoo/xxooCom/xxoo.com.pem;#這是你申請的ssl(Https證書地址)
		ssl_certificate_key  /home/local/xxoo/xxooCom/xxoo.com.key;#這是你申請的ssl(Https證書地址)
		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;
		location / {
			 proxy_pass http://xxoo_web;#http://後面的xxoo_web與**注意1**處要相同
			 proxy_redirect              off;
			proxy_set_header            Host $host; 
			proxy_set_header            Remote_Addr $remote_addr; 
			proxy_set_header            X-REAL-IP  $remote_addr; 
			proxy_set_header            X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header           X-Forwarded-Proto  $scheme;  
		}
	}
	upstream xxoo_web{#**注意1**
		server **服務器外網IP:端口**;   #中間有個**:**
    }
	#網站配置-----結尾

}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章