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