
要在网站根目录 加一个 txt 文件,做验证。 但是 django 网站根目录是无法访问的。
有什么办法可以解决呢?
1 qoo2019 May 6, 2020 via iPhone 放 nginx 啊 |
2 putaozhenhaochi May 6, 2020 via Android Nginx location = |
3 misaka19000 May 6, 2020 放 NGINX 啊。。。。 |
4 python30 OP |
5 hellojay May 6, 2020 via iPhone 还用真放 txt 么,匹配一下 url 直接 httpresonse 这个 txt 内容就可以了 |
7 nightwitch May 6, 2020 nginx 的配置里单独处理一下这个文件,不要转发到 django 上。 |
8 Vegetable May 6, 2020 你这差的有点多,一句两句没办法给你讲清楚,你可以去搜索引擎搜一下 fileauth.txt nginx 这样的关键字,原理是一模一样的 |
9 zachlhb May 6, 2020 via Android nginx 设置匹配不就行了 |
10 wangking May 6, 2020 location ~ ^/MPxxxxxxxxxE.txt { default_type text/html; return 200 'pxxxxxxxxxE'; } 送个你,这个用来做一些验证,爽歪歪 |
11 python30 OP |
12 zachlhb May 6, 2020 via Android 再不会你 django 做个文件名的路由,用 view 把文本内容返回回去也可以啊 |
13 veoco May 6, 2020 参照 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 May 6, 2020 emm....推荐一下,一些 nginx 的技巧 https://blog.ops-coffee.cn/s/jyunn_otq2ntxch0mtcjug |