• 请不要在回答技术问题时复制粘贴 AI 生成的内容
testcaoy7
V2EX  ›  程序员

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

  •  
  •   testcaoy7 · Oct 15, 2017 · 3615 views
    This topic created in 3192 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   ·   2761 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 57ms · UTC 15:20 · PVG 23:20 · LAX 08:20 · JFK 11:20
    ♥ Do have faith in what you're doing.