首页 > 解决方案 > 在 Nginx 中安装 CA 证书文件

问题描述

我试图在我的 nginx 服务器上安装 Ssl。一切正常,但是我在设置我的 CA 捆绑文件时收到错误。我不知道如何将我的 CA 文件放在 nginx 中。对于 apache,我们像这样放置包括 CA 文件的证书文件

SSLEngine on

 SSLCertificateFile      /etc/apache2/ssl/example_com.crt
 SSLCertificateKeyFile /etc/apache2/ssl/example.com.key
 SSLCertificateChainFile /etc/apache2/ssl/example_com.ca-bundle 

我们如何将它放在 Nginx 中。这是我的 nginx 的配置文件

server {
        root /var/www/html/example/dist;
        index index.html index.htm index.nginx-debian.html;

  server_name example.com;
server_name www.example.com;

  location / {
     try_files $uri $uri/ /index.html;
  }

  location /example/ {
      proxy_pass http://localhost:3013/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;
  }

   ssl_certificate /etc/nginx/ssl/example_com.crt;
   # ssl_certificate /etc/nginx/ssl/CAbundle.crt;
    ssl_certificate_key /etc/nginx/ssl/example.key;
   # ssl_trusted_certificate /etc/nginx/ssl/CAbundle.crt;
    ssl_dhparam /etc/nginx/ssl/dhparam-2048.pem;
    listen [::]:443 ssl;
    listen 443 ssl;


}

server {
    if ($host = www.example.com) {
        return 301 https://www.$host$request_uri;
    } 


    if ($host = example.com) {
        return 301 https://www.$host$request_uri;
    } }

标签: nginxnginx-config

解决方案


推荐阅读