nginx - 在 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;
} }
解决方案
推荐阅读
- php - 让用户调用 php 方法的安全隐患
- javascript - 使用带有 CRA/react-scripts 的可选链接(?。)
- java - Java:平面列表
- django - 使用反向功能时出现 NoReverseMatch 错误
- javascript - React Native,为什么 react-native run-android 不起作用?
- c# - Hangfired BackgroundJob.Enqueue 未登录到 Serilog
- c++ - 是否将向量推回向量 UB?
- php - 如何在 phpmailer 中禁用错误消息
- javascript - 关闭另一个模式时打开模式的问题
- python - 重采样轨迹以在每个样本中具有相等的欧几里德距离