lua+nginx 转发https请求有证书错误

具体错误内容如下:

lua ssl certificate verify error: (20: unable to get local issuer certificate)

处理方法

给lua使用一个root账户生成的pem即可,操作方法如下:

ubutu14系统

root@172-18-21-239:/opt/nginx_2.3.2# apt-get install ca-certificates
root@172-18-21-239:/opt/nginx_2.3.2# update-ca-certificates
root@172-18-21-239:/opt/nginx_2.3.2# cp /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-lua.pem
centos系统
yum install ca-certificates
update-ca-trust
cp  /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt /etc/ssl/certs/ca-lua.pem

然后再nginx配置文件添加以下配置

    location / {
        proxy_next_upstream http_502 http_504 error timeout invalid_header;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Real-IP        $remote_addr;

        lua_ssl_verify_depth 2;  # 添加这行和下面这行。
        lua_ssl_trusted_certificate "/etc/ssl/certs/ca-lua.pem" ;

        rewrite_by_lua_file '/opt/nginx_2.3.2/lua_gray/front_proxy.lua';
    }

重启nginx即可了。

关于SSL配置的解释

  1. lua_ssl_verify_depth 官网地址
  2. lua_ssl_trusted_certificate 官网地址
posted @ 2020-12-08 15:33  温柔易淡  阅读(1839)  评论(0编辑  收藏  举报