
要在网站根目录 加一个 txt 文件,做验证。 但是 django 网站根目录是无法访问的。
有什么办法可以解决呢?
1 qoo2019 2020-05-06 17:38:06 +08:00 via iPhone 放 nginx 啊 |
2 putaozhenhaochi 2020-05-06 17:44:52 +08:00 via Android Nginx location = |
3 misaka19000 2020-05-06 17:46:13 +08:00 放 NGINX 啊。。。。 |
OP |
5 hellojay 2020-05-06 17:53:15 +08:00 via iPhone 还用真放 txt 么,匹配一下 url 直接 httpresonse 这个 txt 内容就可以了 |
7 nightwitch 2020-05-06 17:56:11 +08:00 nginx 的配置里单独处理一下这个文件,不要转发到 django 上。 |
8 Vegetable 2020-05-06 17:56:13 +08:00 你这差的有点多,一句两句没办法给你讲清楚,你可以去搜索引擎搜一下 fileauth.txt nginx 这样的关键字,原理是一模一样的 |
9 zachlhb 2020-05-06 17:56:14 +08:00 via Android nginx 设置匹配不就行了 |
10 wangking 2020-05-06 17:57:32 +08:00 location ~ ^/MPxxxxxxxxxE.txt { default_type text/html; return 200 'pxxxxxxxxxE'; } 送个你,这个用来做一些验证,爽歪歪 |
11 python30 OP |
12 zachlhb 2020-05-06 17:58:41 +08:00 via Android 再不会你 django 做个文件名的路由,用 view 把文本内容返回回去也可以啊 |
13 veoco 2020-05-06 18:08:52 +08:00 参照 gunicorn 里面的配置: # path for static files root /path/to/app/current/public; location / { # checks for static file, if not found proxy to app try_files $uri @proxy_to_app; } location @proxy_to_app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; # we don't want nginx trying to do something clever with # redirects, we set the Host: header above already. proxy_redirect off; proxy_pass http://app_server; } |
16 python30 OP 谢谢各位,不一一回复了。 其它的没试验过。 但是做 url 域名匹配的不成功 目前用: location ~ ^/MPxxxxxxxxxE.txt { default_type text/html; return 200 'pxxxxxxxxxE'; } 可以了。 谢谢各位 |
17 37Y37 2020-05-06 18:20:23 +08:00 emm....推荐一下,一些 nginx 的技巧 https://blog.ops-coffee.cn/s/jyunn_otq2ntxch0mtcjug |