nginx配置SSL
时间: 2023-09-03 12:14:55 浏览: 125
要配置Nginx的SSL,可以按照以下步骤进行操作:
1. 首先,在服务器上创建一个目录,并赋予相应的权限。可以使用以下命令创建目录并给予权限:
```
mkdir /home/ssl-nginx/conf
mkdir /home/ssl-nginx/logs
chmod -R 755 /home/ssl-nginx
```
2. 接下来,执行启动命令来运行SSL Nginx容器:
```
docker run -d --privileged=true --name ssl-nginx -p 80:80 -p 443:443 -v /home/ssl-nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /home/ssl-nginx/logs:/var/log/nginx -d nanlist/nginx1.23.1:v1.0
```
3. 然后,可以使用以下命令查看Nginx的日志:
```
docker logs --tail=1000 ssl-nginx
```
4. 进行Nginx的SSL模块安装,可以使用以下命令加载配置文件并重启Nginx容器:
```
docker exec -i ssl-nginx nginx -s reload
```
5. 最后,打开配置文件nginx.conf,并将以下配置内容添加到文件中:
```
http {
server {
listen 443 ssl;
server_name test.com;
ssl_certificate /usr/local/nginx/cert/ssl.crt;
ssl_certificate_key /usr/local/nginx/cert/ssl.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!***5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root /usr/local/service/ROOT;
index index.html;
}
}
server {
listen 80;
server_name test.com;
rewrite ^/(.*)$ https://test.com:443/$1 permanent;
}
}
```
以上就是配置Nginx的SSL的步骤。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Nginx配置ssl证书(https证书)](https://blog.csdn.net/u010797364/article/details/127413419)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [Nginx配置ssl证书(https)](https://blog.csdn.net/ydZ157/article/details/121515518)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文