为 Caddy 增加客户端证书认证,做只为自己服务的反代 - V2EX
请不要在回答技术问题时复制粘贴 AI 生成的内容
testcaoy7

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

  •  
  •   testcaoy7 Oct 15, 2017 3535 views
    This topic created in 3140 days ago, the information mentioned may be changed or developed.
    使用 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 replies    2019-01-29 08:31:04 +08:00
    abmin521
        1
    abmin521  
       Oct 16, 2017
    思路不错 不过手机电脑 都需要一个个导入
    testcaoy7
        2
    testcaoy7  
    OP
       Nov 3, 2017
    今天才发现 xxx.xxx 是一个 HSWZ ……
    纯属巧,不是我故意的
    find456789
        3
    find456789  
       May 13, 2018
    你好,
    我按照你的步骤最后生成的文件里, 没有 xxx.cer 这样的文件,
    请问是我的步骤不对吗,

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

    private/ 目录下有 ca.key xxx.key xxx.p12
    find456789
        5
    find456789  
       May 13, 2018
    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
       Jan 29, 2019
    今天更正一下:
    将“ clients require /root/EasyRSA-3.0.3/pki/ca.crt ” 中的“ require ”删去
    有“ require ”表示“ requires a client certificate, but will not verify it.”
    About     Help     Advertise     Blog     API     FAQ     Solana     5751 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 42ms UTC 06:12 PVG 14:12 LAX 23:12 JFK 02:12
    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