Nginx and SSL Version and DEBUG

Nginx and SSL Version and DEBUG

SSL Support Version
Recently, our nginx get some exceptions as follow:
2018/06/22 14:38:38 [crit] 17#17: *127594 SSL_do_handshake() failed (SSL: error:1417D18C:SSL routines:tls_process_client_hello:version too low) while SSL handshaking, client: 100.111.64.0, server: 0.0.0.0:443
2018/06/22 14:38:59 [warn] 16#16: *127645 using uninitialized "lambda_url" variable, client: 100.110.128.0, server: manage.xxxxxxx.com, request: "GET /api/getPairingCode?serialNumber=xxx&platform=xx_400&firmwareVersion=3.2.1.2088 HTTP/1.1", host: "manage.xxxxxxx.com"

We can easily reproduce that issue with these commands:
> openssl s_client -ssl3 -connect manage4.xxxxxx.com:443
CONNECTED(00000003)
140735735931848:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:s3_pkt.c:1498:SSL alert number 40
140735735931848:error:1409E0E5:SSL routines:ssl3_write_bytes:ssl handshake failure:s3_pkt.c:659:

> openssl s_client -ssl3 -connect manage.xxxxxx.com:443
CONNECTED(00000003)
140735735931848:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:s3_pkt.c:1498:SSL alert number 40
140735735931848:error:1409E0E5:SSL routines:ssl3_write_bytes:ssl handshake failure:s3_pkt.c:659:

From the google information, we can fix that by changing the configuration of NGINX, but it is not suggested.
ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;

How to Turn On DEBUG on NGINX
In the configuration nginx.conf
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log notice;

Need to change the notice to debug in error_log

In the start.sh, Instead of starting it with nginx command, we should use nginx-debug
nginx-debug -g "daemon off;"
#nginx -g "daemon off;"


References:
https://serverfault.com/questions/905011/nginx-ssl-do-handshake-failed-ssl-error1417d18cssl
https://community.letsencrypt.org/t/getting-ssl-do-handshake-error-version-too-low-despite-all-the-effort/58040
### 重新编译并安装带有SSL支持的Nginx #### 准备工作环境 为了确保能够成功编译和安装带有SSL支持的Nginx,需要预先安装必要的开发工具以及依赖库。对于基于Red Hat的企业Linux发行版(如CentOS),可以执行如下命令来更新系统软件包列表并安装所需的编译工具和依赖项: ```bash sudo yum update sudo yum install -y gcc make openssl-devel pcre-devel zlib-devel ``` 而对于基于Debian的系统(如Ubuntu),则应使用`apt-get`来进行相应的操作: ```bash sudo apt-get update sudo apt-get install -y build-essential openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ``` 这些指令会下载并安装用于构建Nginx及其附加功能所需的各种资源[^1][^4]。 #### 获取Nginx源码 前往[Nginx官方网站](http://nginx.org/en/download.html),找到最新的稳定版本链接地址,并通过wget或其他方式获取压缩包;也可以直接利用Git克隆官方仓库到本地机器上。这里假设选择了前者的方式进行下载: ```bash cd /usr/local/src/ wget http://nginx.org/download/nginx-<version>.tar.gz tar zxvf nginx-<version>.tar.gz cd nginx-<version> ``` 请注意替换其中的`<version>`为实际要安装的具体版本号[^5]。 #### 编译配置选项设置 进入解压后的Nginx源代码目录之后,可以通过运行configure脚本来指定额外的功能模块和支持特性。为了让新编译出来的Nginx具备处理HTTPS的能力,在此过程中应当加入`--with-http_ssl_module`参数以启用HTTP SSL/TLS协议的支持。完整的配置命令可能类似于这样: ```bash ./configure \ --modules-path=/usr/lib/nginx/modules \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --pid-path=/run/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --user=www-data \ --group=www-data \ --build=linux64 \ --builddir=nginx-build \ --with-compat \ --with-debug \ --with-http_dav_module \ --with-http_flv_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_mp4_module \ --with-http_random_index_module \ --with-http_realip_module \ --with-http_secure_link_module \ --with-http_slice_module \ --with-mail \ --with-mail_ssl_module \ --add-dynamic-module=njs_src/http/ngx_http_js_module.c ``` 上述命令中的路径和其他选项可以根据实际情况和个人偏好做出调整。特别是当希望集成IPv6支持时,还可以考虑增加`--with-ipv6`标志位[^3]^。 #### 开始编译过程 完成前面所有的准备工作以后,就可以正式开始编译流程了。这一步骤通常只需要简单地调用make即可启动整个编译链路: ```bash make && sudo make install ``` 如果一切顺利的话,经过一段时间等待后就能得到一个全新编译好的Nginx二进制文件连同其配套的相关组件一起被部署到了之前所设定的目标位置处。 #### 测试与验证 最后一步是要确认刚刚安装成功的Nginx确实已经包含了预期的功能模块——即HTTP SSL Module。为此可以在终端里输入以下命令查看当前加载的所有模块清单: ```bash nginx -V 2>&1 | grep "configure arguments:" -A 10 ``` 该输出应该显示出包含有`--with-http_ssl_module`在内的多个编译期参数说明字符串,表明此时此刻正在使用的这个实例确实是按照自定义需求定制过的版本[^2]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值