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

Caddy 怎么配置使用通配符的 acme dns 证书?

  •  
  •   wenerme · 65 天前 · 524 次点击
    这是一个创建于 65 天前的主题,其中的信息可能已经有所发展或是发生改变。
    {
    	http_port 80
    	https_port 443
    
    	log {
    		output stdout
    		level INFO
    		format console
    	}
    
    	acme_dns acmedns {
    		config {
    			"example.com" {
    				username ""
    				password ""
    				subdomain ""
    				fulldomain ""
    				server_url "https://auth.acme-dns.io"
    			}
    		}
    	}
    }
    
    http://:80 {
    	respond / "Hello World" 200
    }
    
    # This works
    example.com {
    	respond / "Hi from Root" 200
    }
    
    # This not work
    web.example.com {
    	respond / "Hi from Web" 200
    }
    

    我想 web.example.com 也能使用 example.com 的通配证书

    4 条回复    2024-07-05 08:11:24 +08:00
    wenerme
        1
    wenerme  
    OP
       65 天前
    正确写法是这样的

    ```
    *.example.com {
    tls {
    dns <provider_name> [<params...>]
    }

    @foo host foo.example.com
    handle @foo {
    respond "Foo!"
    }

    @bar host bar.example.com
    handle @bar {
    respond "Bar!"
    }

    # Fallback for otherwise unhandled domains
    handle {
    abort
    }
    }
    ```

    万万没想到
    daisyfloor
        2
    daisyfloor  
       65 天前
    如果我对某个域名还要处理 handle_path

    怎么写?

    比如

    handle_path /xyz/* {
    reverse_proxy xyz:9527
    }
    daisyfloor
        3
    daisyfloor  
       64 天前
    知道了 直接全部在 handle 里处理,类似这样

    handle @bitwarden {
    encode gzip
    reverse_proxy /notifications/hub/negotiate nas:7777
    reverse_proxy /notifications/hub nas:3012
    reverse_proxy nas:7777
    }
    daisyfloor
        4
    daisyfloor  
       64 天前
    也可以 这样

    handle @foo {
    handle_path /api/* {
    reverse_proxy localhost:8080
    }

    handle {
    reverse_proxy localhost:9080
    }
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1126 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 23:44 · PVG 07:44 · LAX 16:44 · JFK 19:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.