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. 003-shell 传递参数

    一.概述 可以在执行 Shell 脚本时,向脚本传递参数,脚本内获取参数的格式为:$n.n 代表一个数字,1 为执行脚本的第一个参数,2 为执行脚本的第二个参数,以此类推…… 二.实例 以下实例我们向 ...

  2. python学习笔记(十七)网络编程之urllib模块

    如何用python打开一个网站或者请求一个接口呢,我们在这篇博客介绍一下. 首先我们得导入一个urllib模块,这个模块是python自带的标准模块,直接导入就能使用,但是用起来不方便,先看个简单的打 ...

  3. Laravel 5.3 使用内置的 Auth 组件实现多用户认证功能

    https://blog.csdn.net/kevinbai_cn/article/details/54341779 概述 在开发中,我们经常会遇到多种类型的用户的认证问题,比如后台的管理员和前台的普 ...

  4. 聊一聊 Django 中间件

    Django默认的Middleware有七个: MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.cont ...

  5. Extjs3.4 grid中添加一列复选框

    var sm = new Ext.grid.CheckboxSelectionModel(); var cm = new Ext.grid.ColumnModel( [ sm, new Ext.gri ...

  6. VUE 2.0在IE中打开页面空白的原因及解决方法

    前言 因为工作的需要,学习Vue2.0也有一段时间,最近在用Vue2.0的官方脚手架工具构建的项目,chrome中跑一直没有问题,但ie打开出现了bug: 问题 ie打开vue2.0项目空白,控制台报 ...

  7. [转]字符串相似度算法(编辑距离算法 Levenshtein Distance)

    转自:http://www.sigvc.org/bbs/forum.php?mod=viewthread&tid=981 http://www.cnblogs.com/ivanyb/archi ...

  8. Winter-2-STL-G Team Queue 解题报告及测试数据

    Time Limit:3000MS     Memory Limit:0KB Description Queues and Priority Queues are data structures wh ...

  9. CCTableView

    今天用到TableView, 我就来记录一下....这些都是在网上找到了资料 //首先 继承 : public cocos2d::extension::CCTableViewDelegate,publ ...

  10. JCenter下载太慢?教你修改Maven仓库地址为国内镜像

    http://blog.csdn.net/biezhihua/article/details/49668605 转载自:http://www.yrom.net/blog/2015/02/07/chan ...