Nginx的https配置

Nginx的https配置

参考地址(阿里云提交的教程链接):
https://help.aliyun.com/document_detail/212905.html?spm=5176.b657008.help.dexternal.14ae1b48aHgR

遇到的错误:
1、nginx: [emerg] the “ssl” parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:99

提示 Nginx 缺少 http_ssl_module 模块。
  • 查看现有模块./nginx -V
  • 添加SSL模块
# 进入Nginx源码目录
cd /usr/local/nginx-1.20.1
 

# 附加--with-http_ssl_module
./configure --with-http_ssl_module
 

# 运行make命令
make



# 备份
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
 

# 停止
./nginx -s stop
 

# 新编译的Nginx覆盖原来的Nginx(注意一定要保证nginx停止了,才能覆盖成功)
cp /usr/local/nginx-1.20.1/objs/nginx /usr/local/nginx/sbin/
 

# 启动Nginx
./nginx
 

# 再次查看已安装模块,确认是否成功
nginx -V

2、nginx: [emerg] no “ssl_certificate” is defined for the “listen … ssl” directive in /usr/local/nginx/conf/nginx.conf:98
nginx.conf文件的https server配置,我使用下面的配置之后就不报错了:

server {
        listen 443 ssl;
        server_name www.zhanjiang.work;

        ssl_certificate      /usr/local/nginx/cert/sslconfigure.pem;
        ssl_certificate_key  /usr/local/nginx/cert/sslconfigure.key;

        #location /api {
        #    rewrite ^/api/(.*)$ /$1 break;
        #    proxy_pass http://zhfk/;
        #    proxy_set_header X-real-ip $remote_addr;
        #}

        location / {
              root   html;
              index  index.html index.htm;
        }

    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值