nginx https插件
时间: 2023-11-22 12:50:32 浏览: 109
nginx可以通过安装插件来启用HTTPS功能。常用的插件是OpenSSL和Nginx SSL模块。下面是两种启用nginx HTTPS插件的方法:
1. 使用OpenSSL插件:
```shell
# 安装OpenSSL
sudo apt-get install openssl
# 生成SSL证书和私钥
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/private.key -out /etc/nginx/certificate.crt
# 配置nginx
sudo nano /etc/nginx/sites-available/default
# 在server块中添加以下配置
listen 443 ssl;
ssl_certificate /etc/nginx/certificate.crt;
ssl_certificate_key /etc/nginx/private.key;
# 重启nginx
sudo systemctl restart nginx
```
2. 使用Nginx SSL模块:
```shell
# 安装Nginx
sudo apt-get install nginx
# 配置nginx
sudo nano /etc/nginx/sites-available/default
# 在server块中添加以下配置
listen 443 ssl;
ssl_certificate /etc/nginx/certificate.crt;
ssl_certificate_key /etc/nginx/private.key;
# 重启nginx
sudo systemctl restart nginx
```
请注意,以上示例中的证书和私钥路径仅供参考,请根据实际情况进行修改。
阅读全文