为 Caddy 增加客户端证书认证,做只为自己服务的反代 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
testcaoy7

为 Caddy 增加客户端证书认证,做只为自己服务的反代

  •  
  •   testcaoy7 2017 年 10 月 15 日 3491 次点击
    这是一个创建于 3114 天前的主题,其中的信息可能已经有所发展或是发生改变。
    使用 easy-rsa 可以很方便的完成这个任务。
    首先编辑 vars 文件,创建符合自己的模板,然后就是创建证书,命令如下:
    1、init-pki
    2、build-ca nopass
    3、build-client-full <client> nopass
    4、export-p12 <client>

    caddyFile 如下(以反代 rime.im 为例,可以作死的改成某大型搜索引擎):

    https://xxx.xxx {
    gzip
    tls xxx.cer xxx.key {
    clients require /root/EasyRSA-3.0.3/pki/ca.crt
    }
    proxy / http://rime.im/
    }

    http://xxx.xxx {
    redir https://xxx.xxx
    }

    最后是下载<client>.p12 导入到 Firefox 中去,或者装到计算机里去。这样除非装了证书,别人都访问不了反代的小秘密了。
    6 条回复    2019-01-29 08:31:04 +08:00
    abmin521
        1
    abmin521  
       2017 年 10 月 16 日
    思路不错 不过手机电脑 都需要一个个导入
    testcaoy7
        2
    testcaoy7  
    OP
       2017 年 11 月 3 日
    今天才发现 xxx.xxx 是一个 HSWZ ……
    纯属巧合,不是我故意的
    find456789
        3
    find456789  
       2018 年 5 月 13 日
    你好,
    我按照你的步骤最后生成的文件里, 没有 xxx.cer 这样的文件,
    请问是我的步骤不对吗,

    我用的 ubuntu,
    在 github 官方下载的 easy-rsa 3.0.4 版本的
    find456789
        4
    find456789  
       2018 年 5 月 13 日
    issued/ 目录下有个 xxx.crt

    private/ 目录下有 ca.key xxx.key xxx.p12
    find456789
        5
    find456789  
       2018 年 5 月 13 日
    http://xxx.xxx {
    gzip
    tls xxx.cer xxx.key {
    clients require /root/EasyRSA-3.0.3/pki/ca.crt
    }
    proxy / http://xxx.xx/
    }

    http://xxx.xxx {
    redir https://xxx.xxx
    }


    我是这样的配置, 我猜测有可能是 http://xxx.xxx 我没有改成 https 的,因为我是在本地测试,稍后我放上服务器看看
    testcaoy7
        6
    testcaoy7  
    OP
       2019 年 1 月 29 日
    今天更正一下:
    将“ clients require /root/EasyRSA-3.0.3/pki/ca.crt ” 中的“ require ”删去
    有“ require ”表示“ requires a client certificate, but will not verify it.”
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2919 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 43ms UTC 13:34 PVG 21:34 LAX 06:34 JFK 09:34
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86