今天在配置nginx的https访问上遇到一个小问题
当我配置完conf文件之后 使用nginx -s reload重启nginx之后使用https访问域名发现被拒绝访问
当时我想被拒绝访问可能是端口没有打开,于是去安全组件中查看,发现443端口是打开
当我在网上查看了大量的资料都没有提及该问题的和解决方式,我只能自己动手排除问题。
首先我将配置文件删得只剩监听443端口的sever 再次重启发现还是只能通过80端口访问,这时我产生了一个疑问。既然不是443端口没有打开,那么是不是nginx没有监听443端口
于是我查看了下端口监听情况 netstat -lntp
[root@izuf6hb0c8pq4vuut4nc2zz conf]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 2589/./redis-server
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 16884/java
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 14313/nginx: master
tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 4962/epmd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2169/sshd
tcp 0 0 0.0.0.0:8443 0.0.0.0:* LISTEN 16884/java
tcp6 0 0 :::3306 :::* LISTEN 876/mysqld
tcp6 0 0 :::6379 :::* LISTEN 2589/./redis-server
tcp6 0 0 :::4369 :::* LISTEN 4962/epmd
tcp6 0 0 :::33060 :::* LISTEN 876/mysqld
发现nginx果然没有监听443端口 于是我将该master进程kill掉再次运行
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
再次查看端口监听情况
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2169/sshd
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 19884/nginx: master
tcp 0 0 0.0.0.0:8443 0.0.0.0:* LISTEN 16884/java
发现在监听443端口
再次https访问域名成功
在此记录一下