使用nginx配置https域名证书

发布时间 2023-05-05 09:51:18作者: 小肚腩吖
  1. 安装SSL模块
    要在nginx中配置https,就必须安装SSL模块,也就是:http_ssl_module
  • 进入到nginx的解压目录
    img

  • 新增SSL模块(原来的那些模块需要保留)

./configure \
--prefix=/usr/local/nginx \ 
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.local \
--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
  1. 查看模块
cd obj/
ll
vim ngx_modules.c

img
img
3. 配置HTTPS

  • 把SSL正式*.crt和私钥.key拷贝到/usr/local/nginx/conf目录中
  • 新增server监听443端口