婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Nginx 運維之域名驗證的方法示例

Nginx 運維之域名驗證的方法示例

熱門標簽:燃氣管線地圖標注顏色 400電話申請要什么條件 西柏坡地圖標注 寧波400電話辦理對企業的意義 北京人工外呼系統廠家 話術外呼系統 廣東如何申請400電話 哈爾濱400電話去哪辦理 i智能電話機器人yeta

各公眾平臺在配置接口域名時會驗證開發者對域名的配置權, 生成隨機的文本及字符串,讓放置在域名根目錄可以通過域名直接訪問到即通過驗證。

示例為驗證域名 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 的 Location 從零開始配置

nginx 配置返回文本或 json

補充:Nginx域名重定向

1、更改配置文件test.com.conf

[root@jimmylinux-001 vhost]# vim test.com.conf

server
{
  listen 80;
  server_name test.com test2.com test3.com;
  index index.html index.htm index.php;
  root /data/wwwroot/test.com;
  if ($host != 'test.com' ) {
    rewrite ^/(.*)$ http://test.com/$1 permanent;
  }

}

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

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

標簽:巴中 襄陽 阜陽 開封 張家口 西藏 湘潭 珠海

巨人網絡通訊聲明:本文標題《Nginx 運維之域名驗證的方法示例》,本文關鍵詞  Nginx,運維,之,域名,驗證,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Nginx 運維之域名驗證的方法示例》相關的同類信息!
  • 本頁收集關于Nginx 運維之域名驗證的方法示例的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 浦江县| 卫辉市| 岳普湖县| 怀宁县| 巴塘县| 称多县| 恭城| 区。| 青神县| 叙永县| 五华县| 聂拉木县| 镇安县| 白水县| 贵溪市| 和田市| 郴州市| 宁远县| 沈阳市| 房产| 东明县| 华蓥市| 道真| 丹棱县| 海门市| 宿松县| 田东县| 和静县| 隆昌县| 公主岭市| 武宁县| 日照市| 沙湾县| 巨鹿县| 安远县| 邛崃市| 松阳县| 黄石市| 海城市| 和田市| 林甸县|