国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

linux 下生成ssl自簽證書(shū), 并配置nginx通過(guò)https訪問(wèn)

這篇具有很好參考價(jià)值的文章主要介紹了linux 下生成ssl自簽證書(shū), 并配置nginx通過(guò)https訪問(wèn)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

一、之前對(duì)外暴露接口地址為http://192.168.2.246

因?yàn)橛成淞擞蛎?,需要升?jí)為https,由于是IP地址訪問(wèn),所以生成自簽名證書(shū)并設(shè)置nginx

二、home目錄下新建new_cert目錄用于存放證書(shū)以及相關(guān)文件

[root@localhost home]# mkdir new_cert

三、使用openssl分別生成服務(wù)端和客戶端的公鑰及私鑰

1、生成服務(wù)端私鑰

(base) [root@localhost ~]# mkdir new_cert
(base) [root@localhost ~]# cd new_cert/
(base) [root@localhost new_cert]# openssl genrsa -out server.key 1024
Generating RSA private key, 1024 bit long modulus (2 primes)
.......................+++++
............+++++
e is 65537 (0x010001)
    

2、生成服務(wù)端公鑰

(base) [root@localhost new_cert]# openssl rsa -in server.key -pubout -out server.pem
writing RSA key
(base) [root@localhost new_cert]# openssl genrsa -out client.key 1024
Generating RSA private key, 1024 bit long modulus (2 primes)
.........................+++++
..........+++++
e is 65537 (0x010001)

3、生成客戶端私鑰

(base) [root@localhost new_cert]# openssl rsa  -in client.key -pubout -out client.pem
writing RSA key

4、生成客戶端公鑰

(base) [root@localhost new_cert]# ll
total 16
-rw------- 1 root root 887 Apr  6 14:44 client.key
-rw-r--r-- 1 root root 272 Apr  6 14:44 client.pem
-rw------- 1 root root 887 Apr  6 14:43 server.key
-rw-r--r-- 1 root root 272 Apr  6 14:44 server.pem
(base) [root@localhost new_cert]#

四、生成CA證書(shū)

1、生成CA私鑰

(base) [root@localhost new_cert]# openssl genrsa -out ca.key 1024
Generating RSA private key, 1024 bit long modulus (2 primes)
..........+++++
.........................+++++
e is 65537 (0x010001)
(base) [root@localhost new_cert]#

2、生成CA證書(shū)簽名請(qǐng)求文件CSR

(base) [root@localhost new_cert]# openssl req -new -key ca.key -out ca.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:cn
State or Province Name (full name) [Some-State]:beijing
Locality Name (eg, city) []:chaoyang
Organization Name (eg, company) [Internet Widgits Pty Ltd]:hlhk_ca
Organizational Unit Name (eg, section) []:hlhk_sms_ca
Common Name (e.g. server FQDN or YOUR name) []:192.168.2.246
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:192.168.2.246
(base) [root@localhost new_cert]#

3、使用私鑰KEY文件和CSR文件簽名生成CRT證書(shū)

(base) [root@localhost new_cert]# openssl x509 -req -in ca.csr -signkey ca.key -out ca.crt
Signature ok
subject=C = cn, ST = beijing, L = chaoyang, O = hlhk_ca, OU = hlhk_sms_ca, CN = 192.168.2.246
Getting Private key
(base) [root@localhost new_cert]#

五、生成服務(wù)器端和客戶端CRT證書(shū)

1、生成服務(wù)端簽名請(qǐng)求CSR文件

(base) [root@localhost new_cert]# openssl req -new -key server.key -out server.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:cn
State or Province Name (full name) [Some-State]:beijing
Locality Name (eg, city) []:chaoyang
Organization Name (eg, company) [Internet Widgits Pty Ltd]:hlhk_serve
Organizational Unit Name (eg, section) []:hlhk_sms_serve
Common Name (e.g. server FQDN or YOUR name) []:192.168.2.246
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:192.168.2.246
(base) [root@localhost new_cert]#

2、生成客戶端簽名請(qǐng)求CSR文件

(base) [root@localhost new_cert]# openssl req -new -key client.key -out client.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:cn
State or Province Name (full name) [Some-State]:beijing
Locality Name (eg, city) []:chaoyang
Organization Name (eg, company) [Internet Widgits Pty Ltd]:hlhk_client
Organizational Unit Name (eg, section) []:hlhk_sms_client
Common Name (e.g. server FQDN or YOUR name) []:192.168.2.246
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:192.168.2.246
(base) [root@localhost new_cert]#

這里服務(wù)端和客戶端的Organization Name (eg, company)以及Organizational Unit Name都必須要和CA的不一樣才可以文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-501382.html

3、向剛才生成的自己的CA機(jī)構(gòu)申請(qǐng)簽名CRT證書(shū)(服務(wù)端和客戶端)

(base) [root@localhost new_cert]# openssl x509 -req -CA ca.crt -CAkey ca.key -CAcreateserial -in server.csr -out server.crt
Signature ok
subject=C = cn, ST = beijing, L = chaoyang, O = hlhk_serve, OU = hlhk_sms_serve, CN = 192.168.2.246
Getting CA Private Key
(base) [root@localhost new_cert]# openssl x509 -req -CA ca.crt -CAkey ca.key -CAcreateserial -in client.csr -out client.crt
Signature ok
subject=C = cn, ST = beijing, L = chaoyang, O = hlhk_client, OU = hlhk_sms_client, CN = 192.168.2.246
Getting CA Private Key
(base) [root@localhost new_cert]#
(base) [root@localhost new_cert]# ll
total 48
-rw-r--r-- 1 root root 891 Apr  6 14:46 ca.crt
-rw-r--r-- 1 root root 737 Apr  6 14:46 ca.csr
-rw------- 1 root root 891 Apr  6 14:44 ca.key
-rw-r--r-- 1 root root  41 Apr  6 14:50 ca.srl
-rw-r--r-- 1 root root 904 Apr  6 14:50 client.crt
-rw-r--r-- 1 root root 749 Apr  6 14:49 client.csr
-rw------- 1 root root 887 Apr  6 14:44 client.key
-rw-r--r-- 1 root root 272 Apr  6 14:44 client.pem
-rw-r--r-- 1 root root 899 Apr  6 14:49 server.crt
-rw-r--r-- 1 root root 712 Apr  6 14:47 server.csr
-rw------- 1 root root 887 Apr  6 14:43 server.key
-rw-r--r-- 1 root root 272 Apr  6 14:44 server.pem
(base) [root@localhost new_cert]#

六、最后生成需要的key和crt文件

(base) [root@localhost new_cert]# openssl rsa -in server.key -out server_nginx.key
writing RSA key
(base) [root@localhost new_cert]# openssl x509 -req -days 3650 -in server.csr -signkey server_nginx.key -out server_nginx.crt
Signature ok
subject=C = cn, ST = beijing, L = chaoyang, O = hlhk_serve, OU = hlhk_sms_serve, CN = 192.168.2.246
Getting Private key
(base) [root@localhost new_cert]#

七、將key和crt文件上傳到nginx上并配置nginx配置文件(https://xxx.xxx.xxx.xxx:8061)

user  nginx;
worker_processes  8;

error_log  /var/log/nginx/info.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections 1024;
    accept_mutex on;
    multi_accept on;
    use epoll;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8061 ssl;
        server_name  hlhk.com;

        ssl_certificate      /root/new_cert/server_nginx.crt;
        ssl_certificate_key  /root/new_cert/server_nginx.key;

        ssl_session_cache    shared:SSL:1m;
        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://hlhk.com;
            proxy_set_header host $host;
            proxy_set_header X-real-ip $remote_addr;
            proxy_set_header X-forwarded-for $proxy_add_x_forwarded_for;

         }
   }
}

到了這里,關(guān)于linux 下生成ssl自簽證書(shū), 并配置nginx通過(guò)https訪問(wèn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Nginx配置ssl證書(shū)實(shí)現(xiàn)https安全訪問(wèn)

    Nginx配置ssl證書(shū)實(shí)現(xiàn)https安全訪問(wèn)

    目錄 一、Nginx的安裝與配置 安裝步驟 二、SSL證書(shū)獲取 三、Nginx配置 前題條件,擁有服務(wù)器與可以解析到該服務(wù)器的自己的域名。 若已安裝好了Nginx,則需查看自己的Nginx是否開(kāi)啟了SSL的模塊功能: ?顯示如上,則代表ssl功能已開(kāi)啟,否則可能出現(xiàn)以下錯(cuò)誤提示: nginx: [emer

    2024年02月15日
    瀏覽(29)
  • nginx配置監(jiān)聽(tīng)443端口,開(kāi)啟ssl協(xié)議,走 https 訪問(wèn)

    nginx配置監(jiān)聽(tīng)443端口,開(kāi)啟ssl協(xié)議,走 https 訪問(wèn)

    最近有個(gè)項(xiàng)目需要上線到浙政釘工作臺(tái),那邊要求項(xiàng)目走 https 訪問(wèn),但是服務(wù)器沒(méi)有進(jìn)行相應(yīng)的配置一直都是走的 http,于是乎對(duì)服務(wù)器進(jìn)行的一番配置,注明:linux 服務(wù)器 ,記錄一下相關(guān)的踩坑記錄,以及完整版的成功配置流程。 各位找到各自服務(wù)器上的 nginx 安裝目錄,

    2024年02月06日
    瀏覽(28)
  • nginx配置SSL證書(shū)配置https訪問(wèn)網(wǎng)站 超詳細(xì)(附加配置源碼+圖文配置教程)

    最近在阿里云上入手了一臺(tái)云服務(wù)器,準(zhǔn)備搭建一套java程序,在 Nginx 配置SSL證書(shū)時(shí),配上之后前端可以正常以https的方式打開(kāi),但是訪問(wèn)不到后端,自己也是明明知道是 Niginx 配置的問(wèn)題,但就不知道錯(cuò)哪了,當(dāng)時(shí)心里的那種感覺(jué)真是無(wú)法表達(dá)嗚嗚嗚… 經(jīng)過(guò)排查發(fā)現(xiàn) 前端訪

    2024年02月11日
    瀏覽(23)
  • nginx配置監(jiān)聽(tīng)443端口,開(kāi)啟ssl協(xié)議,走 https 訪問(wèn)_nginx 443(1)

    nginx配置監(jiān)聽(tīng)443端口,開(kāi)啟ssl協(xié)議,走 https 訪問(wèn)_nginx 443(1)

    先自我介紹一下,小編浙江大學(xué)畢業(yè),去過(guò)華為、字節(jié)跳動(dòng)等大廠,目前阿里P7 深知大多數(shù)程序員,想要提升技能,往往是自己摸索成長(zhǎng),但自己不成體系的自學(xué)效果低效又漫長(zhǎng),而且極易碰到天花板技術(shù)停滯不前! 因此收集整理了一份《2024年最新Linux運(yùn)維全套學(xué)習(xí)資料》,

    2024年04月22日
    瀏覽(25)
  • Linux下Nginx配置SSL模塊,Nginx安裝SSL,Nginx支持https配置詳細(xì)教程

    Linux下Nginx配置SSL模塊,Nginx安裝SSL,Nginx支持https配置詳細(xì)教程

    前提:Linux安裝Nginx,參考教程:CentOS7安裝Nginx完整教程,Linux系統(tǒng)下保姆式安裝Nginx教程 | 老麻 安裝好Nginx之后,需要支持SSL時(shí),要單獨(dú)安裝SSL模塊,方法如下: 輸入 ./nginx –V 命令,注意V是大寫(xiě),查看配置是否包含“–with-http_ssl_module”,包含則表示已配置好SSL,如果不包

    2024年02月08日
    瀏覽(22)
  • Linux配置Nginx SSL支持Https配置教程

    Linux配置Nginx SSL支持Https配置教程

    繼承上篇 Linux安裝Nginx 執(zhí)行: ./nginx -V 命令 如果有輸出 --–with-http_ssl_module 則說(shuō)明已安裝好SSL模塊 進(jìn)入安裝目錄 /usr/local/nginx-1.22.1 執(zhí)行安裝命令: ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module 執(zhí)行編譯命令: make 注意:make成功后不要執(zhí)行 make insta

    2024年01月18日
    瀏覽(26)
  • nginx編譯以及通過(guò)自定義生成證書(shū)配置https

    nginx編譯以及通過(guò)自定義生成證書(shū)配置https

    nginx安裝編譯安裝以及配置https,需要 gcc-c++ pcre-devel openssl openssl-devel 軟件。因此需要先安裝相關(guān)軟件。 openssl/openssl-devel :主要用于nginx編譯的 http_ssl_module 模塊安裝以及證書(shū)的生成。 依次執(zhí)行如下命令: 解壓壓縮包 執(zhí)行屬性配置 http_ssl_module:支持配置https模塊 –prefix=/us

    2024年02月14日
    瀏覽(19)
  • liunx nginx配置ssl 配置https 及訪問(wèn)失敗問(wèn)題排查(fopen:No such file or )([emerg] the “ssl“ parameter requires)

    liunx nginx配置ssl 配置https 及訪問(wèn)失敗問(wèn)題排查(fopen:No such file or )([emerg] the “ssl“ parameter requires)

    1.ssl證書(shū)下載 比如騰訊云下載目錄: 首先在網(wǎng)址(阿里云、騰訊云等)找到域名ssl下載,下載后解壓里面有xxx.yey、xxx.pem、xxx.crt等文件 在服務(wù)器nginx配置里新建個(gè)文件夾,如我的nginx 在 /usr/local/nginx這個(gè)目錄 2.將ssl證書(shū)文件拷貝至服務(wù)器 如: 3.檢查有沒(méi)有ssl插件(nginx -V 中V大寫(xiě)

    2024年02月13日
    瀏覽(20)
  • SpringBoot + Vue2項(xiàng)目打包部署到服務(wù)器后,使用Nginx配置SSL證書(shū),配置訪問(wèn)HTTP協(xié)議轉(zhuǎn)HTTPS協(xié)議

    SpringBoot + Vue2項(xiàng)目打包部署到服務(wù)器后,使用Nginx配置SSL證書(shū),配置訪問(wèn)HTTP協(xié)議轉(zhuǎn)HTTPS協(xié)議

    配置nginx.conf文件,這個(gè)文件一般在/etc/nginx/...中,由于每個(gè)人的體質(zhì)不一樣,也有可能在別的路徑里,自己找找... 證書(shū)存放位置,可自定義存放位置 兩個(gè)文件 后端配置 把.pfx拷貝到resource下,然后配置一下yml

    2024年02月02日
    瀏覽(100)
  • windows10下設(shè)置本地apache\nginx站點(diǎn)部署ssl證書(shū),使本地配置的域名可以用https訪問(wèn)

    windows10下設(shè)置本地apache\nginx站點(diǎn)部署ssl證書(shū),使本地配置的域名可以用https訪問(wèn)

    首先我們需要下載openssl來(lái)生成證書(shū)文件: 去官方網(wǎng)址下載https://slproweb.com/products/Win32OpenSSL.html; 下載好了,雙擊exe文件,然后就下一步,下一步安裝完成; 安裝之后配置環(huán)境變量,新建一個(gè)系統(tǒng)變量OPENSSL_HOME,值就是你安裝目錄下的bin,然后在系統(tǒng)變量path,增加%OPENSSL_HO

    2024年02月15日
    瀏覽(22)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包