nginx-1.16 htts://domain:port 访问 突然不行了

情景介绍

有个朋友找我说 问一个nginx问题,说以前用 1.6 的版本 的配置文件,放到刚刚升级的 nginx1.16 版本下不能用了,不能访问了

了解到,他的配置有点奇葩,需要使用 https://domain:port 这样的访问方式

一下把我问蒙了,第一个反应是 一个 server下面 写两个 linsten 端口,我自己也手动测试了下,我使用的是 nginx-1.12 ,按照我的构想配置,是没问题的。

但我朋友的还是不行,于是乎远程上去一顿操作

我操作的流程:

  1. 查看朋友的nginx 所有配置是否正常 结果是都正常
  2. 怀疑是nginx版本太高,不兼容,手动安装 1.14 后测试同样不能访问,那说明跟版本关系不太大
  3. 还是配置问题,推倒 朋友的 配置文件,按我的思路来配置,在1.14版本上成功了

结局

最后按照我的思路,在1.14版本上测试成功,于是把配置直接拷贝到 1.16版本下,测试

在 使用 nginx -t 检测配置的时候,报错如下:

[root@HS-30 conf.d]# nginx -t
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/conf.d/yusuan.conf:4
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

这里有个警告,在第四行,查了下是 1.15 之后,nginx 不再使用 ssl on; 这个配置了,所以是个警告。

于是下意识就把这行删除后,就不警告了,重启发现还是不能访问

我火大了。。突然反应过来刚刚删除的 ssl on; 配置,重新添加回来,不管警告,直接reload。网页出来了。。。解决

只是在 reload 的时候还会警告

[root@HS-30 conf.d]# nginx -t
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/conf.d/yusuan.conf:4
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@HS-30 conf.d]# /etc/init.d/nginx restart
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/conf.d/yusuan.conf:4
Stopping nginx:                                            [  OK  ]
Starting nginx: nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/conf.d/yusuan.conf:4
                                                           [  OK  ]
[root@HS-30 conf.d]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
You have mail in /var/spool/mail/root
[root@HS-30 conf.d]# 

直接忽略警告即可。

总结

虽然 nginx 1.15 版本之后不再使用 ssl on; 这个配置了,但似乎还是起到一些作用,具体不知道。。。

但这只是个警告,直接忽略就可以了。

最后 还是建议 按照正常配置来把。。这种奇葩的访问方式有点受不了。。。

就是这样 https://domain:port 看着总是怪怪的

最后给出我朋友的访问连接: https://192.168.255.168:64630 这样的访问方式。。。蛋疼

原文地址:https://www.cnblogs.com/winstom/p/12404837.html