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. spring MVC 学习(四)---拦截器,视图解析器

    1.接口HandlerInterceptor 该接口包含3个方法,分别是preHandle,postHandle,afterCompletion,分别代表着执行前,执行后,执行完成要执行的方法,其中p ...

  2. python学习笔记(二十六)经典类和新式类的区别

    首先了解一下什么是经典类,什么是新式类 class Person: #经典类 pass class Person2(object): #新式类 pass #类名首字母都大写 #在python3里面经典 ...

  3. HDU中大数实现的题目,持续更新(JAVA实现)

    HDU1002:大数加法,PE了N次 import java.util.Scanner; import java.math.*; public class Main { public static v ...

  4. 安装pip环境以及pip常用命令使用

    1.去到Python的官网下载pip包,下载地址是:https://pypi.python.org/pypi/pip#downloads 2.下载完成之后,解压到一个文件夹,用CMD控制台进入解压目录 ...

  5. Http协议面试题

    1.说一下什么是Http协议? 对器客户端和 服务器端之间数据传输的格式规范,格式简称为“超文本传输协议”. 2.什么是Http协议无状态协议?怎么解决Http协议无状态协议?(曾经去某创业公司问到) ...

  6. 并发容器-ConcurrentHashMap,CopyOnWriteArrayList

    ConcurrentHashMap HashMap是线程非安全的,在多线程环境下,采用的是Fail-Fast快速失败机制,即当A线程在访问容器的时候,如果此时B线程修改了HashMap的结构,那么就会 ...

  7. c++之旅:函数模板

    函数模板 函数模板主要是泛型在函数的中的应用,通过泛型可以让函数处理各种各样的数据类型 简单的列子 #include <iostream> using namespace std; tem ...

  8. windows上使用clang编译程序

    环境:windows7,64位 1.下载并安装llvm,安装包里除了llvm,也有clang: http://releases.llvm.org/5.0.0/LLVM-5.0.0-win64.exe ...

  9. NOIP2019前的训练记录

    \(April\):肛多项式,学\(FWT\)一个小时无果后背了六个公式,看来证明又得咕很久了

  10. mspdb100.dll不见了的解决办法

    一.如果在运行某软件或编译程序时提示缺少.找不到mspdb100.dll等类似提示,将下载来的mspdb100.dll拷贝到指定目录即可 (一般是system系统目录或放到软件同级目录里面),或者重新 ...