濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > Nginx 運(yùn)維之域名驗(yàn)證的方法示例

Nginx 運(yùn)維之域名驗(yàn)證的方法示例

熱門(mén)標(biāo)簽:燃?xì)夤芫€地圖標(biāo)注顏色 400電話申請(qǐng)要什么條件 西柏坡地圖標(biāo)注 寧波400電話辦理對(duì)企業(yè)的意義 北京人工外呼系統(tǒng)廠家 話術(shù)外呼系統(tǒng) 廣東如何申請(qǐng)400電話 哈爾濱400電話去哪辦理 i智能電話機(jī)器人yeta

各公眾平臺(tái)在配置接口域名時(shí)會(huì)驗(yàn)證開(kāi)發(fā)者對(duì)域名的配置權(quán), 生成隨機(jī)的文本及字符串,讓放置在域名根目錄可以通過(guò)域名直接訪問(wèn)到即通過(guò)驗(yàn)證。

示例為驗(yàn)證域名 abc.com 可以通過(guò)根路由訪問(wèn) 6CysNYj8Hb.txt 響應(yīng)體為字符串 01df2ddab4774ba2676a5563ccb79ffa。

$ curl https://abc.com/6CysNYj8Hb.txt
01df2ddab4774ba2676a5563ccb79ffa

方案一

配置有 root 的 server,直接把隨機(jī)文檔放置在該目錄下即可,不需要重啟 nginx 服務(wù)。

方案二

匹配路由,指定隨機(jī)文檔所在目錄, 需要重啟 nginx。

location ~* 6CysNYj8Hb\.txt {
 root /data/ftp;
}

方案三(推薦)

匹配路由,直接返回需要驗(yàn)證的隨機(jī)字符串,需要重啟 nginx。

location = /6CysNYj8Hb.txt {
 default_type text/html;
 return 200 '01df2ddab4774ba2676a5563ccb79ffa';
}

參考

Nginx 的 Location 從零開(kāi)始配置

nginx 配置返回文本或 json

補(bǔ)充: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測(cè)試

[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

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

標(biāo)簽:巴中 襄陽(yáng) 阜陽(yáng) 開(kāi)封 張家口 西藏 湘潭 珠海

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Nginx 運(yùn)維之域名驗(yàn)證的方法示例》,本文關(guān)鍵詞  Nginx,運(yùn)維,之,域名,驗(yàn)證,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Nginx 運(yùn)維之域名驗(yàn)證的方法示例》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于Nginx 運(yùn)維之域名驗(yàn)證的方法示例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    临洮县| 北辰区| 新源县| 瑞昌市| 海宁市| 滦南县| 田东县| 盈江县| 济阳县| 化德县| 南川市| 莲花县| 丹凤县| 政和县| 建水县| 大石桥市| 牟定县| 慈溪市| 镇远县| 陈巴尔虎旗| 台南县| 绍兴县| 钟山县| 清远市| 嵊泗县| 白城市| 镇沅| 延长县| 忻城县| 龙门县| 扎赉特旗| 弋阳县| 大厂| 新野县| 乌拉特后旗| 嘉祥县| 祁阳县| 唐山市| 桐庐县| 井研县| 托里县|