Movatterモバイル変換


[0]ホーム

URL:


API

Basic API for Caddy

Caddy admin

Initial functions


source

get_id

 get_id (path)

Get a ID full URL from a path

host='jph.answer.ai'
get_id('jph.answer.ai')
'http://localhost:2019/id/jph.answer.ai/'

source

get_path

 get_path (path)

Get a config full URL from a path

get_path('/apps/tls/automation/policies')
'http://localhost:2019/config/apps/tls/automation/policies/'

source

gid

 gid (path='/')

Gets the id atpath


source

has_id

 has_id (id)

Check ifid is set up


source

gcfg

 gcfg (path='/', method='get')

Gets the config atpath


source

has_path

 has_path (path)

Check ifpath is set up

gcfg()

source

pid

 pid (d, path='/', method='post')

Puts the configd intopath


source

pcfg

 pcfg (d, path='/', method='post')

Puts the configd intopath

# pcfg({})

source

nested_setdict

 nested_setdict (sd, value, *keys)

Returnssd updated to setvalue at the pathkeys

nested_setdict({'a':'b'}, {'c':'d'},'apps','http','servers','srv0')
{'a': 'b', 'apps': {'http': {'servers': {'srv0': {'c': 'd'}}}}}

source

path2keys

 path2keys (path)

Splitpath by ‘/’ into a list

path2keys('/apps/tls/automation/policies')
['apps', 'tls', 'automation', 'policies']

source

keys2path

 keys2path (*keys)

Joinkeys into a ‘/’ separated path

keys2path('apps','tls','automation','policies')
'/apps/tls/automation/policies'

source

nested_setcfg

 nested_setcfg (value, *keys)

source

init_path

 init_path (path, skip=0)

Automation setup

cf_token= os.environ.get('CADDY_CF_TOKEN','XXX')

source

get_acme_config

 get_acme_config (token)

source

add_tls_internal_config

 add_tls_internal_config ()

source

add_acme_config

 add_acme_config (cf_token)
# add_acme_config(cf_token)
# gcfg('/apps/tls/automation/policies')[0]

Route setup


source

init_routes

 init_routes (srv_name='srv0', skip=1)

Create basic http server/routes config

init_routes()

source

setup_pki_trust

 setup_pki_trust (install_trust)

Configure PKI certificate authority trust installation


source

setup_caddy

 setup_caddy (cf_token=None, srv_name='srv0', local:bool=False,              install_trust:bool=None)

Create SSL config and HTTP app skeleton

TypeDefaultDetails
cf_tokenNoneTypeNoneCloudflare API token
srv_namestrsrv0Server name in the Caddyfile
localboolFalseWhether or not this is for localdev or deployment
install_trustboolNoneInstall trust store?
# pcfg({})setup_caddy(cf_token)
# gcfg(srvs_path)

source

add_route

 add_route (route)

Addroute dict to config


source

del_id

 del_id (id)

Delete route forid (e.g. a host)

# del_id(host)

source

add_reverse_proxy

 add_reverse_proxy (from_host, to_url, st_delay='1m', compress:bool=True)

Create a reverse proxy handler

host='foo.fast.ai'
# add_reverse_proxy(host, "localhost:5001")
# gid(host)

source

add_wildcard_route

 add_wildcard_route (domain)

Add a wildcard subdomain

add_wildcard_route('something.fast.ai')

source

add_sub_reverse_proxy

 add_sub_reverse_proxy (domain, subdomain, port:Union[str,int,Sequence],                        host='localhost', st_delay='1m', encode:bool=True)

Add a reverse proxy to a wildcard subdomain supporting multiple ports

TypeDefaultDetails
domain
subdomain
portUnionA single port or list of ports
hoststrlocalhost
st_delaystr1m
encodeboolTrue
add_sub_reverse_proxy('something.fast.ai','foo',5001)
del_id('foo.something.fast.ai')

[8]ページ先頭

©2009-2025 Movatter.jp