https nginx
时间: 2023-12-23 20:28:07 浏览: 46
以下是使用nginx配置https的步骤:
1. 下载和安装nginx:
```shell
wget http://nginx.org/download/nginx.1.20.1.tar.gz
```
2. 解压nginx压缩包:
```shell
tar -zxvf nginx.1.20.1.tar.gz
```
3. 进入nginx目录:
```shell
cd nginx-1.20.1
```
4. 配置编译参数:
```shell
./configure --with-http_ssl_module
```
5. 编译和安装nginx:
```shell
make
sudo make install
```
6. 生成SSL证书和私钥:
```shell
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /usr/local/nginx/conf/nginx.key -out /usr/local/nginx/conf/nginx.crt
```
7. 配置nginx.conf文件:
```shell
sudo vi /usr/local/nginx/conf/nginx.conf
```
在http块中添加以下内容:
```shell
server {
listen 443 ssl;
server_name your_domain.com;
ssl_certificate /usr/local/nginx/conf/nginx.crt;
ssl_certificate_key /usr/local/nginx/conf/nginx.key;
location / {
root html;
index index.html index.htm;
}
}
```
8. 启动nginx:
```shell
sudo /usr/local/nginx/sbin/nginx
```
现在,您的nginx服务器已经配置为使用https。