• Caddy神奇: http服务免ssl证书改造为https


    最近在godaddy上买了个.dev的域名,但是这个后缀的域名只支持https和ssl解析。换句话说解析的时候,会把http请求强制转化为https。如果应用不支持https,则会直接解析失败。

    详细介绍见:https://sg.godaddy.com/zh/help/about-dev-domains-32019

    自己服务器上有搭建一个code-server作为日常笔记使用,由于自签证书会比较麻烦(比如:ipad上无法导入自签证书,无法使用。)所以选了caddy作为https的代理服务器。

    caddy是一个http服务器,和nginx,apache一样,但是有个很厉害的特性,可以0配置支持https,它的基本原理很简单,基于zerossl和let's encrypt,并且自动轮换证书,实现了免手动配置证书的

    一、安装caddy

    sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
    curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/cfg/gpg/gpg.155B6D79CA56EA34.key' | sudo apt-key add -
    curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/cfg/setup/config.deb.txt?distro=debian&version=any-version' | sudo tee -a /etc/apt/sources.list.d/caddy-stable.list
    sudo apt update
    sudo apt install caddy
    

    二、启动code-server,监听在localhost:8080端口上

    三、配置caddy,配置文件在/etc/caddy/Caddyfile里

    假设域名是code.test.dev直接A记录指向服务器ip,由于test.dev域名只能解析https,这里配置caddy监听在443端口,reverse_proxy指定方向代理,代理到localhost:8080

    code.test.dev:443 {
            root * /usr/share/caddy
            reverse_proxy localhost:8080
    }

    四、启动caddy并加入开机自启

    systemctl start caddy
    systemctl enable caddy

    到这里caddy就配置结束了

    接下来直接访问https://code.test.dev,就可以看到code-server。利用这个方式,还可以将其他服务都低配置转换为https

  • 相关阅读:
    实验室机器OracleXE客户端连接远程Oracle服务器
    PLSQL Developer 远程连接Oracle XE数据库(其他Oracle数据库类似)
    VB进制转化大全
    给定一个硬盘标识,umout掉所有相关挂载
    linux读取硬盘指定扇区
    开发板上挂载NTFS分区
    write error:file too large!!!
    一些自用的c函数
    主引导记录(MBR)分析
    strtok_r函数学习
  • 原文地址:https://www.cnblogs.com/zlgxzswjy/p/16224984.html
Copyright © 2020-2023  润新知