参考地址(阿里云提交的教程链接):
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;
}
}



