国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > Nginx > 正文

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

2024-08-30 12:24:42
字體:
供稿:網(wǎng)友

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

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

$ curl https://abc.com/6CysNYj8Hb.txt01df2ddab4774ba2676a5563ccb79ffa

方案一

配置有 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 從零開始配置

nginx 配置返回文本或 json

補(bǔ)充:Nginx域名重定向

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

[root@jimmylinux-001 vhost]# vim test.com.confserver{  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 -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: 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 -IHTTP/1.1 301 Moved PermanentlyServer: nginx/1.12.1Date: Thu, 07 Jun 2018 16:47:36 GMTContent-Type: text/htmlContent-Length: 185Connection: keep-aliveLocation: http://test.com/index.html[root@jimmylinux-001 vhost]# curl -x127.0.0.1:80 test2.com/admin/index.html -IHTTP/1.1 301 Moved PermanentlyServer: nginx/1.12.1Date: Thu, 07 Jun 2018 16:48:08 GMTContent-Type: text/htmlContent-Length: 185Connection: keep-aliveLocation: http://test.com/admin/index.html[root@jimmylinux-001 vhost]# curl -x127.0.0.1:80 test3.com/admin/index.html/adjlfj -IHTTP/1.1 301 Moved PermanentlyServer: nginx/1.12.1Date: Thu, 07 Jun 2018 16:48:35 GMTContent-Type: text/htmlContent-Length: 185Connection: keep-aliveLocation: http://test.com/admin/index.html/adjlfj[root@jimmylinux-001 vhost]# curl -x127.0.0.1:80 test4.com/admin/index.html/adjlfj -IHTTP/1.1 404 Not FoundServer: nginx/1.12.1Date: Thu, 07 Jun 2018 16:48:43 GMTContent-Type: text/htmlContent-Length: 169Connection: keep-alive

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持錯(cuò)新站長站。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 波密县| 犍为县| 保亭| 维西| 龙井市| 淮阳县| 广东省| 万全县| 汉阴县| 西丰县| 天气| 开远市| 岳普湖县| 保德县| 榆中县| 漳州市| 兰西县| 平泉县| 无为县| 泾川县| 辽阳县| 隆昌县| 白水县| 汾西县| 朝阳县| 宜丰县| 会东县| 九龙城区| 永年县| 鞍山市| 永年县| 达日县| 福泉市| 富源县| 保靖县| 东辽县| 鹤山市| 浑源县| 乌兰浩特市| 塘沽区| 循化|