nginx页面不能访问

  • nginx页面不能访问

    • 检查服务端服务是否启动成功
    • 在服务端使用wget和curl测试下返回的是否正常
    • 浏览器wget或者curl等软件访问不了Ngixn页面

1. 检查服务端服务是否启动成功

[root@shizhan02 html]# ps -ef |grep nginx  #查看nginx服务是否启动
root 1609 1 0 16:46 ? 00:00:00 nginx: master process nginx
nginx 1610 1609 0 16:46 ? 00:00:00 nginx: worker process
root 1898 1593 0 18:09 pts/0 00:00:00 grep nginx

  '

[root@shizhan02 html]# lsof -i :80  #检查80端口是否在监听状态
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 1609 root 6u IPv4 11948 0t0 TCP *:http (LISTEN)
nginx 1610 nginx 6u IPv4 11948 0t0 TCP *:http (LISTEN)

  

[root@shizhan02 html]# netstat -lnt |grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN

  

2.在服务端使用wget和curl测试下返回的是否正常

[root@shizhan02 html]# wget 127.0.0.1
--2017-11-20 18:16:58-- http://127.0.0.1/
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK #返回值200表示链接正常
Length: 612 [text/html]
Saving to: “index.html.2” 100%[===============================================================>] 612 --.-K/s in 0s 2017-11-20 18:16:58 (279 MB/s) - “index.html.2” saved [612/612] [root@shizhan02 html]# curl 127.0.0.1 #返回页面的值表示正常。
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html>

  

以上是检测Nginx在服务端安装及浏览是否正常。

3.浏览器,wget或者curl等软件访问不了Ngixn页面。

 1. 关闭SEliun
```
[root@shizhan02 html]# getenforce #查看iptables状态,是否为关闭,以下为关闭状
态,
Disabled
[root@shizhan02 html]# vim /etc/selinux/config #永久关闭iptalbes
SELINUX=disabled #需要将此行更改为disabled
SELINUXTYPE=targeted [root@shizhan02 html]# setenforce 0 #临时关闭iptables的方法,如果临时能够访问
了,那么久使用下面的方法添加80端口在iptables的配置文件上
setenforce: SELinux is disabled [root@shizhan02 html]# service iptables status #检查iptables
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination Chain FORWARD (policy ACCEPT)
num target prot opt source destination Chain OUTPUT (policy ACCEPT)
num target prot opt source destination 问题不是出在nginx上,而是出在iptable上,在iptable上添加80端口 Linux代码 收藏代码
#vi /etc/sysconfig/iptables
//在倒数第二行加入80端口
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j
ACCEPT //重启iptables
#/etc/init.d/iptables restart
再通过ip访问 ok~ 没问题了
```
2. 通过本地客服端测试
第一步:在客服端ping服务端的ip,我这里的的服务端为192.168.1.202
```
[root@shizhan02 html]# ping 192.168.1.202
PING 192.168.1.202 (192.168.1.202) 56(84) bytes of data.
64 bytes from 192.168.1.202: icmp_seq=1 ttl=64 time=0.014 ms
64 bytes from 192.168.1.202: icmp_seq=2 ttl=64 time=0.024 ms
^C
--- 192.168.1.202 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1814ms
rtt min/avg/max/mdev = 0.014/0.019/0.024/0.005 ms
#提示按ctrl+c结束
```
第二步:在客户端上telnet服务端ip,端口
```
[root@shizhan02 html]# telnet 192.168.1.202 #返回如下信息表示链接成功
Trying 192.168.1.202...
telnet: connect to address 192.168.1.202: Connection refused
``` 第三步:在客服端使用wget或者curl命令检测。
```
[root@shizhan02 html]# curl -i 192.168.1.202
HTTP/1.1 200 OK
Server: nginx/1.13.6
Date: Mon, 20 Nov 2017 10:42:31 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Mon, 20 Nov 2017 08:08:26 GMT
Connection: keep-alive
ETag: "5a128d7a-264"
Accept-Ranges: bytes <!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully
installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html>
```
3. 在浏览器访问输入如下的内容,服务器ip. http://192.168.1.202/ ![nginx已经能够成功访问](https://img-blog.csdn.net/20171120104737429?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjk3NjczMTc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
这里有一个小小的坑,希望大家注意一下,使用浏览器输入ip访问的时候,注意清空一下缓存,或者重新打开一下浏览器,有可能让你一直刷新不出页面。

  

nginx页面不能正常访问排除方法的更多相关文章

  1. 【转】Linux下nginx配置https协议访问的方法

    一.配置nginx支持https协议访问,需要在编译安装nginx的时候添加相应的模块--with-http_ssl_module 查看nginx编译参数:/usr/local/nginx/sbin/ ...

  2. Linux下nginx配置https协议访问的方法

    一.配置nginx支持https协议访问,需要在编译安装nginx的时候添加相应的模块--with-http_ssl_module 查看nginx编译参数:/usr/local/nginx/sbin/ ...

  3. WebForm.aspx 页面通过 AJAX 访问WebForm.aspx.cs类中的方法,获取数据

    WebForm.aspx 页面通过 AJAX 访问WebForm.aspx.cs类中的方法,获取数据 WebForm1.aspx 页面 (原生AJAX请求,写法一) <%@ Page Langu ...

  4. WebForm.aspx 页面通过 AJAX 访问WebForm.aspx.cs类中的方法,获取数据(转)

    WebForm.aspx 页面通过 AJAX 访问WebForm.aspx.cs类中的方法,获取数据 WebForm1.aspx 页面 (原生AJAX请求,写法一) <%@ Page Langu ...

  5. 本地主机访问不了nginx 页面,请求超时

    虚拟机可以正常访问nginx页面,但是电脑浏览器访问不了,一番排差,防火墙的问题. /etc/init.d/iptables stop

  6. nginx 配置虚拟主机访问PHP文件 502错误的解决方法

    最近配置Nginx 服务器虚拟主机 访问目录发现报502错误 百度了很多方法 都不管用  我擦 各种抓狂----- 原本Nginx配置如下: 网上找了很多方法: 查看日志   借助nginx的错误日志 ...

  7. HTML:减少页面加载时间的方法

    1. 重复的HTTP请求数量应尽量减少 (1)减少调用其他页面.文件的数量. (2)在使用css格式时,常会采用background载入图形文件,而每个background的图像都会产生1次HTTP ...

  8. nginx只允许域名访问,禁止ip访问

    背景:为什么要禁止ip访问页面呢?这样做是为了避免其他人把未备案的域名解析到自己的服务器IP,而导致服务器被断网,我们可以通过禁止使用ip访问的方法,防止此类事情的发生. 解决方法:这里介绍修改配置文 ...

  9. nginx只允许域名访问,禁止ip访问 禁止其他域名访问

    背景:为什么要禁止ip访问页面呢?这样做是为了避免其他人把未备案的域名解析到自己的服务器IP,而导致服务器被断网,我们可以通过禁止使用ip访问的方法,防止此类事情的发生. 解决方法:这里介绍修改配置文 ...

随机推荐

  1. html5游戏开发-零基础开发《圣诞老人送礼物》小游戏

    开言: 以前lufy前辈写过叫“ HTML5游戏开发-零基础开发RPG游戏”的系列文章,在那里面我学习了他的引擎以及了解了游戏脚本.自从看了那几篇文章,我便对游戏开发有了基本的认识.今天我也以零基础为 ...

  2. 网站实时信息采集和统计graphite

    Graphite 是一个Python写的web应用,采用django框架,Graphite用来进行收集服务器所有的即时状态,用户请求信息,Memcached命中率,RabbitMQ消息服务器的状态,U ...

  3. idea的junit测试出现Class not found: "com.chinaums.szm.test.RouteTransProxyClientTest" Empty test suite.

  4. 48. Rotate Image(旋转矩阵)

      You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise) ...

  5. spark[源码]-Pool分析

    概述 这篇文章主要是分析一下Pool这个任务调度的队列.整体代码量也不是很大,正好可以详细的分析一下,前面在TaskSchedulerImpl提到大体的功能,这个点在丰富一下吧. DAGSchedul ...

  6. PHP开发之apache mac上配置

    我使用的Mac OS X版本是10.8.2,Mac自带了Apache环境. 启动Apache 设置虚拟主机 启动Apache 打开“终端(terminal)”,输入 sudo apachectl -v ...

  7. oracle过程书写规范

    ORACLE存储过程编码规范 1.1         变量规范 Ø        变量名全部采用小写,局部变量名使用“v_”开头,输入参数以“i_开头,输出参数以“o_”开头,输入输出参数用io_开头 ...

  8. 对Spring Ioc 以及DI的精彩理解

    转:http://blog.csdn.net/cyjs1988/article/details/50352916 学习过spring框架的人一定都会听过Spring的IoC(控制反转) .DI(依赖注 ...

  9. 编写和运行简单的"Hello World"操作系统内核

    通常编写一个操作系统内核是一项浩大的工程.但我今天的目标是制作一个简单的内核,用比较方便的方法在虚拟机上验证它能够被grub装载和运行,并且可通过gdb进行调试,为接下去的工作创造一个基础环境. 首先 ...

  10. Kafka学习之(四)PHP操作Kafka

    简单测试 环境:Centos6.4,PHP7,kafka服务器IP:192.168.9.154,PHP服务器:192.168.9.157 在192.168.9.157创建目录和文件. //生产者 &l ...