1.通过curl -I 获取当前链接的信息(主要是获取重定向信息)
例如:
$ curl -I http://m.2234sad.com/mipd/251631.html
HTTP/1.1 301 Moved Permanently
Date: Sun, 29 Sep 2019 01:33:34 GMT
Content-Length: 0
Connection: keep-alive
Server: Cdn Cache Server V2.0
Location: https://m.2234sad.com/mipd/251631.html
X-Via: 1.0 zhoudxin74:1 (Cdn Cache Server V2.0)
2.然后 curl 重定向地址 #获取重定向地址内容
例如:
$ curl https://m.2234sad.com/mipd/251631.html #看下是啥内容,是不是你需要的或者别的在进行处理
1.通过curl链接内容,一般是403都会返回403内容页面
$curl http://m.yangyys.com/games/alogdyan/
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx</center>
</body>
</html>
2.通过curl -I 获取真正的状态码信息(最好这样确认一下,小心总没错)
$curl -sI http://m.yangyys.com/games/alogdyan/
HTTP/1.1 403 Forbidden
Date: Sun, 29 Sep 2019 01:46:11 GMT
Content-Type: text/html; charset=utf8
Content-Length: 162
Connection: keep-alive
Server: nginx
X-Via: 1.1 PSfjqzdx7qy86:9 (Cdn Cache Server V2.0), 1.1 tandianxin122:16 (Cdn Cache Server V2.0)
3.看下是否用了代理(主要是查看当前域名解析的ip跟你资产登记管理当前项目的实际ip是否一样,一样就不是代理,不一样是代理,但是大部分服务器都是通过代理让用户进行访问)
$curl -v http://m.yangyys.com/games/alogdyan/
* Trying 192.168.1.59...
* TCP_NODELAY set
* Connected to yangyys (192.168.1.59) port 80 (#0)
> GET /games/alogdyan/ HTTP/1.1
> Host:m.yangyys.com
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 403 Forbidden
< Date: Sun, 29 Sep 2019 01:48:26 GMT
< Content-Type: text/html; charset=utf8
< Content-Length: 162
< Connection: keep-alive
< Server: nginx
< X-Via: 1.1 PSfjqzdx7qy86:9 (Cdn Cache Server V2.0), 1.1 PShnsydx2gz230:8 (Cdn Cache Server V2.0)
<
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx</center>
</body>
</html>
* Connection #0 to host m.yangyys.com left intact
4.找到当前项目的项目信息,当前解析ip跟真实提供服务的进行对比(一般自己经手的项目一眼就可以看出是不是代理),然后我通过自己登记的当前项目信息发现真正提供服务的主机ip是192.168.1.69,跟备用服务器192.168.1.79
$curl -v -x 192.168.1.69:80 http://m.yangyys.com/games/alogdyan/
* Trying 192.168.1.69...
* TCP_NODELAY set
* Connected to 192.168.1.69 (192.168.1.69) port 80 (#0)
> GET http://m.96u.com/games/alogdyan/ HTTP/1.1
> Host: m.yangyys.com
> User-Agent: curl/7.54.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 403 Forbidden
< Server: nginx
< Date: Sun, 29 Sep 2019 02:18:32 GMT
< Content-Type: text/html; charset=utf8
< Content-Length: 162
< Connection: keep-alive
<
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx</center>
</body>
</html>
* Connection #0 to host 192.168.1.69 left intact
#注:真正提供服务的这台机器,已经确认当前目录是有问题的,然后到这个台服务器找到此目录具体问题具体分析
$curl -v -x 192.168.1.79:80 http://m.yangyys.com/games/alogdyan/
* Trying 192.168.1.79...
* TCP_NODELAY set
* Connected to 175.6.2.179 (175.6.2.179) port 80 (#0)
> GET http://m.96u.com/games/alogdyan/ HTTP/1.1
> Host: m.yangyys.com
> User-Agent: curl/7.54.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx
< Date: Sun, 29 Sep 2019 02:21:19 GMT
< Content-Type: text/html
< Content-Length: 178
< Connection: keep-alive
< Location: https://m.yangyys.com/games/alogdyan/
<
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
* Connection #0 to host 192.168.1.79 left intact
#注:发现这方面还有301跳转,继续跟踪,查看当前地址的具体内容
$curl --resolve m.yangyys.com:443:192.168.1.79 https://m.yangyys.com/games/alogdyan/
#注:发现果然是一个存在的内容,然后可以登录这台服务器进行处理
总结:对于403状态的查询思路:首先明确当前连接是不是403状态——了解当前连接是否是启用了代理(不是代理就去当前服务器上找指定的问题,是通过代理进行下一步操作)——通过代理连接真实服务器查询连接的状态(返回状态是403就上当前服务器上找到对应的数据查询原因并解决,返回301就进行下一步)——通过curl --resove 或者修改host方式绑定域名及host解析对应的地址信息,获取url内容,在进行处理。