V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
wildcat007
V2EX  ›  问与答

caddy 能不能像 nginx 一样配置 访问网站需要账号密码?

  •  
  •   wildcat007 · 2018-09-11 17:11:06 +08:00 · 2663 次点击
    这是一个创建于 2054 天前的主题,其中的信息可能已经有所发展或是发生改变。
    5 条回复    2018-09-11 18:26:49 +08:00
    halczy
        1
    halczy  
       2018-09-11 17:17:59 +08:00
    jerry
        2
    jerry  
       2018-09-11 17:18:03 +08:00 via iPhone
    wildcat007
        3
    wildcat007  
    OP
       2018-09-11 17:25:24 +08:00
    @halczy
    @jerry
    嗯这个我看了的 但是这个 basicauth 貌似只是针对文件和目录?
    path is the file or directory to protect

    我相对某一个网站,在访问的时候 填入账户 密码~类似 nginx 那种验证
    momocraft
        4
    momocraft  
       2018-09-11 17:28:26 +08:00
    不如试一下
    wildcat007
        5
    wildcat007  
    OP
       2018-09-11 18:26:49 +08:00
    OK 解决 使用 http.jwt 和 http.login 插件即可
    @halczy
    @jerry
    @momocraft

    配置如下

    xxx.com {
    log /xx/xx/xx/xx.log
    tls [email protected]
    gzip
    timeouts none
    proxy / http://127.0.0.1:28080 {
    header_upstream Host {host}
    header_upstream X-Real-IP {remote}
    header_upstream X-Forwarded-For {remote}
    header_upstream X-Forwarded-Proto {scheme}
    }

    jwt {
    path /
    allow sub bob
    }

    login {
    simple name=password
    }
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2789 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 03:52 · PVG 11:52 · LAX 20:52 · JFK 23:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.