网站首页 > 技术教程 正文
各公众平台在配置接口域名时会验证开发者对域名的配置权, 生成随机的文本及字符串,让放置在域名根目录可以通过域名直接访问到即通过验证。
示例为验证域名 abc.com 可以通过根路由访问 6CysNYj8Hb.txt 响应体为字符串 01df2ddab4774ba2676a5563ccb79ffa。
$ curl https://abc.com/6CysNYj8Hb.txt 01df2ddab4774ba2676a5563ccb79ffa
方案一
配置有 root 的 server,直接把随机文档放置在该目录下即可,不需要重启 nginx 服务。
方案二
匹配路由,指定随机文档所在目录, 需要重启 nginx。
location ~* 6CysNYj8Hb\.txt {
root /data/ftp;
}
方案三(推荐)
匹配路由,直接返回需要验证的随机字符串,需要重启 nginx。
location = /6CysNYj8Hb.txt {
default_type text/html;
return 200 '01df2ddab4774ba2676a5563ccb79ffa';
}
补充:Nginx域名重定向
1、更改配置文件test.com.conf
2、curl测试
[root@jimmylinux-001 vhost]# /usr/local/nginx/sbin/nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful [root@jimmylinux-001 vhost]# /usr/local/nginx/sbin/nginx -s reload [root@jimmylinux-001 vhost]# curl -x127.0.0.1:80 test2.com/index.html -I HTTP/1.1 301 Moved Permanently Server: nginx/1.12.1 Date: Thu, 07 Jun 2018 16:47:36 GMT Content-Type: text/html Content-Length: 185 Connection: keep-alive Location: http://test.com/index.html [root@jimmylinux-001 vhost]# curl -x127.0.0.1:80 test2.com/admin/index.html -I HTTP/1.1 301 Moved Permanently Server: nginx/1.12.1 Date: Thu, 07 Jun 2018 16:48:08 GMT Content-Type: text/html Content-Length: 185 Connection: keep-alive Location: http://test.com/admin/index.html [root@jimmylinux-001 vhost]# curl -x127.0.0.1:80 test3.com/admin/index.html/adjlfj -I HTTP/1.1 301 Moved Permanently Server: nginx/1.12.1 Date: Thu, 07 Jun 2018 16:48:35 GMT Content-Type: text/html Content-Length: 185 Connection: keep-alive Location: http://test.com/admin/index.html/adjlfj [root@jimmylinux-001 vhost]# curl -x127.0.0.1:80 test4.com/admin/index.html/adjlfj -I HTTP/1.1 404 Not Found Server: nginx/1.12.1 Date: Thu, 07 Jun 2018 16:48:43 GMT Content-Type: text/html Content-Length: 169 Connection: keep-alive
后面小编会分享更多运维方面的干货,感兴趣的朋友走一波关注哩~
猜你喜欢
- 2024-09-19 Tomcat获取Nginx反向代理的客户端域名
- 2024-09-19 在centos7 创建基于域名的虚拟主机nginx服务器
- 2024-09-19 在 Go 代码中如何绑定 Host?(git绑定github)
- 2024-09-19 记录使用Nginx完成一个域名根据User-Agent适配PC和手机
- 2024-09-19 nginx反向代理禁止ip访问及泛解析访问限制(禁止非法域名解析)
- 2024-09-19 Nginx 反向代理任意请求的域名(nginx反向代理域名访问)
- 2024-09-19 高性能Nginx服务器-DNS域名解析概述
- 2024-09-19 搭建gitlab自定义域名(gitlab局域网搭建)
- 2024-09-19 【Docker入门】Nginx反向代理做前端,多个Docker容器共存做后端
- 2024-09-19 Nginx域名配置(nginx域名配置端口 为啥端口丢了)
欢迎 你 发表评论:
- 12-16无线密码破解用什么软件(无线密码破解软件哪个好)
- 12-16360路由器设置登录(360路由器登陆口)
- 12-16安全平台教育平台登录(安全平台教育登录账号入口)
- 12-16win7装机版系统(win7系统装机教程)
- 12-151500元以内最强笔记本(懂行的人建议买华为还是联想)
- 12-15电脑很卡怎么办快速解决方法
- 12-15tmp文件是什么文件(tmp文件有什么用)
- 12-15win10教育版如何激活(windows10教育版激活密钥怎么激活)
- 最近发表
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)

本文暂时没有评论,来添加一个吧(●'◡'●)