caddyship 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +128 -2
- package/dist/cli.js +1422 -0
- package/package.json +47 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 caddyship contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,129 @@
|
|
|
1
|
-
#
|
|
1
|
+
# caddyship
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Publish Docker apps behind [Caddy](https://caddyserver.com) from your terminal, over SSH.
|
|
4
|
+
Optionally creates the DNS record at [WEDOS](https://www.wedos.com) in the same step.
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
$ caddyship add
|
|
8
|
+
◇ Nickname ropa-deck
|
|
9
|
+
◇ Which domain? china26.fun (or "Enter my own domain...")
|
|
10
|
+
◇ Subdomain ropa
|
|
11
|
+
◇ Point it at This server (203.0.113.7)
|
|
12
|
+
◇ Docker host port ropa-deck 8741 -> 8741
|
|
13
|
+
◇ Apply this? Yes
|
|
14
|
+
✔ DNS record created
|
|
15
|
+
✔ Applying the Caddy config (validate, then reload)
|
|
16
|
+
Live: https://ropa.china26.fun
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Why
|
|
20
|
+
|
|
21
|
+
Editing a production Caddyfile by hand over SSH is easy to get wrong, and DNS lives in a
|
|
22
|
+
different browser tab. `caddyship` does both, and cannot leave a broken config behind:
|
|
23
|
+
every change is validated by Caddy first and rolled back automatically if validation or
|
|
24
|
+
the reload fails.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
npm install -g caddyship # or: npx caddyship
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Requires Node 20+ and an OpenSSH client on your machine. On the server you need Caddy
|
|
33
|
+
and either root or a user with passwordless `sudo`.
|
|
34
|
+
|
|
35
|
+
## Quick start
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
caddyship init # SSH target, Caddy detection, port range, WEDOS credentials
|
|
39
|
+
caddyship doctor # verifies everything, including security hints
|
|
40
|
+
caddyship add # interactive: nickname -> domain -> subdomain -> IP -> port
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Commands
|
|
44
|
+
|
|
45
|
+
| Command | What it does |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| `init` | Create or update a server profile. Detects systemd vs. Docker Caddy, adds one `import` line to your Caddyfile (with backup). |
|
|
48
|
+
| `add` | Interactive flow, or fully scripted with flags (see below). |
|
|
49
|
+
| `list` | Sites managed by caddyship (`--json` for scripts). |
|
|
50
|
+
| `remove <nickname>` | Removes the Caddy block; optionally deletes the DNS record it created. |
|
|
51
|
+
| `ports` | Used/free ports, next free port. `--range 8100-8999` and `--reserve 8080,8081` save settings. |
|
|
52
|
+
| `doctor` | Checks SSH, sudo, Caddy config, Docker, public IP and WEDOS access. |
|
|
53
|
+
|
|
54
|
+
### `add` flow
|
|
55
|
+
|
|
56
|
+
1. **Nickname**: a label so you remember which project owns which domain.
|
|
57
|
+
2. **Domain**: pick one of your WEDOS domains, or enter your own (no WEDOS call is made for your own).
|
|
58
|
+
3. **Subdomain** (WEDOS domains only).
|
|
59
|
+
4. **IP address**: this server, or another one. Pointing at another machine creates the DNS
|
|
60
|
+
record only, because Caddy here could not get a certificate for it.
|
|
61
|
+
5. **Docker port**: choose a running container (its published port is filled in), take the
|
|
62
|
+
next free port in your configured range, or type one.
|
|
63
|
+
|
|
64
|
+
### Scripted use
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
caddyship add --nickname ropa-deck --wedos-domain china26.fun --sub ropa --ip this --port 8741 --yes
|
|
68
|
+
caddyship add --nickname blog --custom-domain blog.example.com --port 8200 --yes
|
|
69
|
+
caddyship add ... --dry-run # print the plan and the Caddy block, change nothing
|
|
70
|
+
caddyship remove ropa-deck --yes --delete-dns
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## How it works
|
|
74
|
+
|
|
75
|
+
- Each site is one file in a directory caddyship owns (default `/etc/caddy/sites/<nickname>.caddy`).
|
|
76
|
+
Your Caddyfile gets a single line, `import /etc/caddy/sites/*.caddy`, and is otherwise untouched.
|
|
77
|
+
- Every change: write file -> `caddy validate` -> reload. If validation or reload fails, the
|
|
78
|
+
previous state is restored. Removed sites are kept under `sites/.removed/`.
|
|
79
|
+
- Site metadata (nickname, port, DNS record) lives in a header comment inside each file, so
|
|
80
|
+
state travels with the server and works from any machine.
|
|
81
|
+
- Everything user-typed that reaches the Caddyfile is validated against strict patterns.
|
|
82
|
+
- DNS is created first and checked on public resolvers (up to 90 s, `--no-dns-wait` to skip),
|
|
83
|
+
so Caddy's certificate challenge can succeed when it reloads.
|
|
84
|
+
|
|
85
|
+
## WEDOS DNS
|
|
86
|
+
|
|
87
|
+
Enable WAPI in the WEDOS customer panel, set a **WAPI password** (separate from your account
|
|
88
|
+
password) and add the public IP of the computer you run `caddyship` from to the **allow-list**.
|
|
89
|
+
|
|
90
|
+
- Only the SHA-1 of the WAPI password is stored (the API never needs the plain password).
|
|
91
|
+
The config file `~/.config/caddyship/config.json` is created with mode `0600`.
|
|
92
|
+
- Existing records are never overwritten silently: a differing A/AAAA record stops the run
|
|
93
|
+
unless you confirm or pass `--update-dns`; an existing CNAME is refused.
|
|
94
|
+
- Apex records (no subdomain) are not supported yet.
|
|
95
|
+
|
|
96
|
+
## Security notes
|
|
97
|
+
|
|
98
|
+
`doctor` warns when containers publish ports on all interfaces (Docker's default for
|
|
99
|
+
`ports: ["8741:8741"]`). Those ports stay reachable directly, bypassing Caddy, TLS and any
|
|
100
|
+
auth you add there. Bind them to loopback instead: `ports: ["127.0.0.1:8741:8741"]`.
|
|
101
|
+
|
|
102
|
+
## Docker-hosted Caddy (experimental)
|
|
103
|
+
|
|
104
|
+
`init` offers Docker mode when it finds a Caddy container. The sites directory must be
|
|
105
|
+
mounted into the container, and `reverse_proxy` must be able to reach published host ports
|
|
106
|
+
(default upstream host in this mode: `host.docker.internal`, which needs
|
|
107
|
+
`extra_hosts: ["host.docker.internal:host-gateway"]`).
|
|
108
|
+
|
|
109
|
+
## Status
|
|
110
|
+
|
|
111
|
+
0.1.0. The WEDOS client follows the official WAPI documentation and community clients and is
|
|
112
|
+
covered by tests against a mock server; run `caddyship doctor` once against your real account.
|
|
113
|
+
Planned: `edit`, adopting existing Caddyfile blocks, apex records, running WAPI calls from the
|
|
114
|
+
server so only its IP needs allow-listing.
|
|
115
|
+
|
|
116
|
+
## Development
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
npm install
|
|
120
|
+
npm test # unit tests + apply/rollback tests against a fake server
|
|
121
|
+
npm run build # bundles to dist/cli.js
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`CADDYSHIP_CONFIG` overrides the config path; `CADDYSHIP_WAPI_ENDPOINT` points the WEDOS
|
|
125
|
+
client at a mock server; `CADDYSHIP_NO_MUX=1` disables SSH connection sharing.
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
MIT
|