Nginx
使用Nginx配置HTTPS域名证书
1.查看nginx是否有nginx模块
方法1:./nginx -V
方法2:cd objs/
vim ngx_modules.c 查找ssl
如果没有:重新编译配置文件
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--with-http_ssl_module

make && make install
2.配置HTTPS
- 把ssl证书*.crt和私钥*.key拷贝到/usr/local/nginx/conf目录中。
- 新增 server 监听 443 端口:
# HTTPS server
#
server {
listen 443 ssl;
server_name localhost;
ssl_certificate *.crt;
ssl_certificate_key *.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}
nginx -t
nginx -s reload
本文介绍了如何在Nginx服务器上配置HTTPS域名证书,确保网站安全通信。首先,检查Nginx是否已编译SSL模块,如果没有则重新配置并安装。接着,将SSL证书和私钥文件拷贝到指定目录,并编辑Nginx配置文件,设置监听443端口,加载证书和密钥。最后,通过`nginx -t`检查配置无误后,使用`nginx -s reload`命令重启Nginx以应用更改。
4944

被折叠的 条评论
为什么被折叠?



