openssl generates a CA certificate and configures it in nginx

refer to:

http://www.linuxidc.com/Linux/2013-08/88271.htm

https://linux.cn/article-5443-weibo.html

 

ios requirements for HTTPS certificate

 

mkdir CA

cd CA

 

1. Generate a certificate

1. Generate a 2048-bit SHA-256 RSA private key for the root

openssl genrsa -aes256 -out a.key 2048

2. Copy a key file that does not require a password

openssl rsa -in a.key -out nopass.key

3. Generate a certificate request

openssl req -new -key a.key -out a.csr

4. Sign the certificate yourself

openssl req -sha256 -new -x509 -days 3650 -key a.key -out a.crt

 

 

Be careful when typing

Country is a 2-digit shortcode

Common Name is your domain name

 

2. Configure the certificate to nginx

The installation process is relatively simple (omitted) /usr/local/etc/nginx/ on the directory I installed

vi edit the nginx.conf file in the nginx root directory

server {

#       server_name YOUR_DOMAINNAME_HERE;

        listen       443;

        server_name  localhost;

        ssl on;

        ssl_certificate /Users/ivy/CA/a.crt;

        ssl_certificate_key /Users/ivy/CA/nopass.key;

        index index.html;

        root /Users/ivy/index.html;

 

        

        location /HideSeekApi/ {

             proxy_pass http://127.0.0.1:8084/;

        }

 

(Other configuration content or comments omitted)

}

 

The default port of nginx listen is 80, and port 443 can be ignored on the final https address

 

 

The location configuration is to jump from nginx to my local service. The default config/path is fine. /HideSeekApi/ is the added path

 

 

3. Configure the domain name to hosts

127.0.0.1     www.51jubaobao.com

 

The ip of niginx is 192.168.100.116

I also need to configure host to access my nginx server on 192.188.100.146

192,168,100,116 www.*******.com

 

 Then you can access it by ignoring the certificate in the browser

https://www.*****.com/HideSeekApi/.......

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326755234&siteId=291194637