创建https证书

第一个里程碑:创建https证书

创建文件认证目录

mkdir /application/nginx/key/ -p

在认证目录下创建认证文件

  1. openssl req -new -x509 -nodes -out server.crt -keyout server.key
  2.  
  3. Generating a 2048 bit RSA private key
  4. .......+++
  5. ......................................+++
  6. writing new private key to 'server.key'
  7. -----
  8. You are about to be asked to enter information that will be incorporated
  9. into your certificate request.
  10. What you are about to enter is what is called a Distinguished Name or a DN.
  11. There are quite a few fields but you can leave some blank
  12. For some fields there will be a default value,
  13. If you enter '.', the field will be left blank.
  14. -----
  15. Country Name (2 letter code) [XX]:CH
  16. State or Province Name (full name) []:bj
  17. Locality Name (eg, city) [Default City]:bj
  18. Organization Name (eg, company) [Default Company Ltd]: 回车
  19. Organizational Unit Name (eg, section) []: 回车
  20. Common Name (eg, your name or your server's hostname) []: 回车
  21. Email Address []: 回车

编写 nginx配置文件 (在负载均衡上配置)

  1. worker_processes 1;
  2. events {
  3.     worker_connections 1024;
  4. }
  5. http {
  6.     include mime.types;
  7.     default_type application/octet-stream;
  8.     sendfile on;
  9.     keepalive_timeout 65;
  10.     upstream www_pools {
  11.       server 10.0.0.8;
  12.    }
  13.     upstream bbs_pools {
  14.       server 10.0.0.7;
  15.    }
  16.     upstream blog_pools {
  17.       server 10.0.0.9;
  18.     }
  19.     server {
  20.         listen 443 ssl;
  21.         listen 80;
  22.         server_name www.etiantian.org;
  23.         ssl_certificate /application/nginx/key/server.crt;
  24.         ssl_certificate_key /application/nginx/key/server.key;
  25.         ssl_session_cache shared:SSL:1m;
  26.         ssl_session_timeout 5m;
  27.         ssl_ciphers HIGH:!aNULL:!MD5;
  28.         ssl_prefer_server_ciphers on;
  29.         location / {
  30.             proxy_pass http://www_pools;
  31.             proxy_set_header Host $host;
  32.             proxy_set_header X-Forwarded-For $remote_addr;
  33.         }
  34.     }
  35.     server {
  36.         listen 80;
  37.             server_name bbs.etiantian.org;
  38.         location / {
  39.             proxy_pass http://bbs_pools;
  40.             proxy_set_header Host $host;
  41.             proxy_set_header X-Forwarded-For $remote_addr;
  42.         }
  43.     }
  44.         server {
  45.         listen 80;
  46.             server_name c.etiantian.org;
  47.         location / {
  48.             proxy_pass http://bbs_pools;
  49.             proxy_set_header Host $host;
  50.             proxy_set_header X-Forwarded-For $remote_addr;
  51.         }
  52.     }
  53.  
  54.     server {
  55.         listen 80;
  56.             server_name blog.etiantian.org;
  57.         location / {
  58.             proxy_pass http://blog_pools;
  59.             proxy_set_header Host $host;
  60.             proxy_set_header X-Forwarded-For $remote_addr;
  61.         }
  62.     }
  63. }

测试

转载于:https://www.cnblogs.com/jksbaduen/p/7816747.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Linux上创建HTTPS证书,您可以按照以下步骤进行操作: 1. 安装必要的软件: 在终端中运行以下命令以安装OpenSSL软件包: ``` sudo apt-get update sudo apt-get install openssl ``` 2. 生成私钥: 使用以下命令生成一个私钥文件(例如,私钥文件名为`private.key`): ``` openssl genrsa -out private.key 2048 ``` 3. 创建证书签名请求(CSR): 使用以下命令生成一个CSR文件(例如,CSR文件名为`csr.pem`): ``` openssl req -new -key private.key -out csr.pem ``` 在运行上述命令后,您将被要求提供一些证书相关的信息,例如国家/地区、组织名称、域名等。请根据您的实际情况提供相关信息。 4. 自签名证书(可选): 如果您只是想创建一个自签名证书,而不是通过权威的证书颁发机构(CA)获取证书,可以使用以下命令生成一个自签名证书文件(例如,证书文件名为`certificate.crt`): ``` openssl x509 -req -days 365 -in csr.pem -signkey private.key -out certificate.crt ``` 请注意,自签名证书不会被所有客户端信任,因此在实际使用中可能会出现安全警告。 5. 通过CA获取证书(可选): 如果您希望获得由权威的证书颁发机构(CA)签发的证书,您需要向CA提交CSR文件,并按照其指示进行进一步的操作。CA通常会要求您进行域名验证和身份验证等步骤。 完成验证和审核后,您将收到由CA签发的证书文件。将该文件保存为`certificate.crt`。 请注意,上述步骤中生成的私钥和证书文件都应该妥善保管,并且私钥应该保持机密性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值