V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
pc10201
V2EX  ›  Python

如何在 nginx 和 django 处理网站验证文件.txt

  •  
  •   pc10201 · 2015-08-26 17:53:44 +08:00 · 2753 次点击
    这是一个创建于 3174 天前的主题,其中的信息可能已经有所发展或是发生改变。
    有一些服务需要验证域名权限,要求你放一个 txt 在网站根目录下
    以前在 php 的网站中,直接扔上去就行了

    自己用 django,nginx,uwsgi 做了一个网站,怎么实现上面的功能?
    自己写的规则

    location ~* \.(txt )$ {
    root /home/wwwroot/xxxx/;
    }

    怎么都不起作用,直接写死吧,感觉又不太灵活~
    6 条回复    2015-08-26 21:41:55 +08:00
    kslr
        1
    kslr  
       2015-08-26 18:07:42 +08:00
    什么都不用写,默认都指向了
    nealnote
        2
    nealnote  
       2015-08-26 18:09:49 +08:00
    加 meta 的方法,验证一般都有几种方法,
    meta 用完,删掉
    wangyongbo
        3
    wangyongbo  
       2015-08-26 20:48:49 +08:00
    location ~\.(txt|html )$ {
    root /wwwwwwwwwwwwwwwwwwwww/;
    }

    我这么写,可以用。
    mkeith
        4
    mkeith  
       2015-08-26 21:27:11 +08:00
    django 加个路由呗 sample.com/xxx.txt
    msg7086
        5
    msg7086  
       2015-08-26 21:34:32 +08:00
    location = /abcdefg.txt {
    root /var/xyz/;
    }

    这种用等号直接指定文件的规则优先级最高。
    gamexg
        6
    gamexg  
       2015-08-26 21:41:55 +08:00
    dns txt 更方便。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2569 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:22 · PVG 22:22 · LAX 07:22 · JFK 10:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.