nginx配置https自簽名(openssl生成)證書-創(chuàng)新互聯(lián)

openssl生成證書

  1. openssl genrsa -out server.key 2048
  2. openssl req -new -key server.key -out server.csr
  3. openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
[nginx@machine certificate]$  openssl genrsa -out server.key 2048
Generating RSA private key, 2048 bit long modulus
..+++
......................................................................+++
e is 65537 (0x10001)
[nginx@machine certificate]$ ll
total 4
-rw-r----- 1 nginx nginx 1679 Jul 11 16:35 server.key
[nginx@machine certificate]$ 
[nginx@machine certificate]$ 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) [XX]:cn
State or Province Name (full name) []:gd
Locality Name (eg, city) [Default City]:gz
Organization Name (eg, company) [Default Company Ltd]:ai
Organizational Unit Name (eg, section) []:ai
Common Name (eg, your name or your server's hostname) []:
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[nginx@machine certificate]$ 
[nginx@machine certificate]$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Signature ok
subject=/C=cn/ST=gd/L=gz/O=ai/OU=ai
Getting Private key
[nginx@machine certificate]$ ll
total 12
-rw-r----- 1 nginx nginx 1099 Jul 11 16:36 server.crt
-rw-r----- 1 nginx nginx  952 Jul 11 16:35 server.csr
-rw-r----- 1 nginx nginx 1679 Jul 11 16:35 server.key
[nginx@machine certificate]$ 

nginx配置

[nginx@machine ~]$ cd /etc/nginx/
[nginx@machine nginx]$ more nginx.conf

為企業(yè)提供成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、外貿(mào)營銷網(wǎng)站建設(shè)、網(wǎng)站優(yōu)化、成都全網(wǎng)營銷推廣、競價(jià)托管、品牌運(yùn)營等營銷獲客服務(wù)。創(chuàng)新互聯(lián)建站擁有網(wǎng)絡(luò)營銷運(yùn)營團(tuán)隊(duì),以豐富的互聯(lián)網(wǎng)營銷經(jīng)驗(yàn)助力企業(yè)精準(zhǔn)獲客,真正落地解決中小企業(yè)營銷獲客難題,做到“讓獲客更簡單”。自創(chuàng)立至今,成功用技術(shù)實(shí)力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡(luò)品牌塑造、網(wǎng)絡(luò)營銷”三大難題,同時(shí)降低了營銷成本,提高了有效客戶轉(zhuǎn)化率,獲得了眾多企業(yè)客戶的高度認(rèn)可!

user nginx;
worker_processes 1;

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

events {
worker_connections 1024;
}

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

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;

keepalive_timeout  65;

#gzip  on;

upstream zuul_nginx {
    server 10.13.22.104:8080;
    server 10.13.22.105:8080;
    server 10.13.22.106:8080;
    server 10.13.22.107:8080;
}

server {
    listen 18010 ssl;
    #listen 443 ssl;
    #server_name 10.13.22.124;
    ssl on;
    ssl_certificate /app/nginx/certificate/server.crt;
    ssl_certificate_key /app/nginx/certificate/server.key;
    ssl_session_timeout  5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers   on;
    location /ouyidaorder {
        proxy_pass http://zuul_nginx;
    }
}

server {
    listen 8080 ssl;
    ssl on;
    ssl_certificate /app/nginx/certificate/server.crt;
    ssl_certificate_key /app/nginx/certificate/server.key;
    ssl_session_timeout  5m;
    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 /ouyidaorder {
        proxy_pass http://zuul_nginx;
    }
}

include /etc/nginx/conf.d/*.conf;

}

用root重啟nginx。

測試

(1)瀏覽器訪問:https://10.13.22.124:8080/ouyidaorder/api/Subscribe
(2)curl https://10.13.22.124:18010/ouyidaorder/api/Subscribe

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

分享文章:nginx配置https自簽名(openssl生成)證書-創(chuàng)新互聯(lián)
分享地址:http://bm7419.com/article44/iijee.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)用戶體驗(yàn)、做網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站維護(hù)、企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名