日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

配置nginx代理实现https访问

發布時間:2024/1/1 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 配置nginx代理实现https访问 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

配置nginx代理實現https訪問

Google宣布從Chrome網絡瀏覽器的下一個穩定版本(90)開始,將為地址欄中輸入的所有URL網址默認選擇HTTPS協議。這意味著未啟用HTTPS的網站的打開速度將受到影響。
對于尚不支持HTTPS的網站,當HTTPS嘗試失敗(包括名稱不匹配或不受信任的自簽名證書之類的證書錯誤,或DNS解析失敗的連接錯誤)時,Chrome會退回到HTTP。

一、nginx安裝

1、 下載安裝包

mkdir /opt/nginx cd /opt/nginx wget http://nginx.org/download/nginx-1.20.2.tar.gz wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz wget http://zlib.net/zlib-1.2.11.tar.gz wget https://netix.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz

2、 安裝c++編譯環境

sudo yum install gcc-c++

3、安裝perl(非必須,如果安裝OpenSSL時提示You need Perl 5,則需安裝)

tar -xzf perl-5.30.1.tar.gz cd perl-5.30.1 ./Configure -des -Dprefix=$HOME/localperl make make test make install

4、 安裝OpenSSL

tar -zxvf openssl-fips-2.0.10.tar.gz cd openssl-fips-2.0.10/ ./config && make && make install

5、 安裝pcre

tar -zxvf pcre-8.40.tar.gz cd pcre-8.40/ ./configure && make && make install yum -y install openssl openssl-devel

6、 安裝zlib

tar -zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11/ ./configure && make && make install

7、 安裝nginx

tar -zxvf nginx-1.20.2.tar.gz cd nginx-1.20.2/ ./configure --with-http_ssl_module && make && make install

8、 啟動nginx

[root@hhh nginx-1.20.2]# whereis nginx nginx: /usr/local/nginx [root@hhh nginx]# cd /usr/local/nginx/ [root@hhh nginx]# ls conf html logs sbin [root@hhh nginx]# /usr/local/nginx/sbin/nginx [root@hhh nginx]#

9、 nginx基本操作

啟動 [root@localhost ~]# /usr/local/nginx/sbin/nginx 停止/重啟 [root@localhost ~]# /usr/local/nginx/sbin/nginx -s stop(quit、reload) 命令幫助 [root@localhost ~]# /usr/local/nginx/sbin/nginx -h 驗證配置文件 [root@localhost ~]# /usr/local/nginx/sbin/nginx -t 配置文件 [root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf 查看nginx進程 [root@x86-103 nginx]# ps -aux | grep nginx root 2814713 0.0 0.0 32980 392 ? Ss 14:38 0:00 nginx: master process /usr/local/nginx/sbin/nginx nobody 2814714 0.0 0.2 66588 4216 ? S 14:38 0:00 nginx: worker process root 2843725 0.0 0.0 12112 1112 pts/1 R+ 14:39 0:00 grep --color=auto nginx

二、配置反向代理

編輯nginx.conf文件
文件中找到“HTTPS server”字樣,將下方注釋放開,按照如下配置,配置完成后重啟nginx。

三、獲取SSL證書

從阿里云獲取免費SSL證書
1、 購買域名(top域名首年1元)。

2、 購買完成域名后可0元購買一年ssl證書

3、 創建證書-證書申請


4、 配置域名解析dns

5、 驗證-提交審核
一般很快即可審核成功

6、 下載SSL證書文件
選擇NGINX進行下載,即可獲得pem和key文件

四、https訪問

一定要保證,證書申請時填寫的域名、dns配置的域名解析,以及本地nginx使用的證書文件一致,并且最終訪問時使用填寫的域名訪問,證書才有效,否則就會出現下面的情況(證書無效)。



總結

以上是生活随笔為你收集整理的配置nginx代理实现https访问的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。