This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
esxi:caddy_server [2024/07/26 10:01] derek |
esxi:caddy_server [2025/12/25 09:41] (current) derek |
||
|---|---|---|---|
| Line 4: | Line 4: | ||
| ====Setup==== | ====Setup==== | ||
| - | * Set up DNS with Cloudflare using the [web: | + | * Set up DNS with Cloudflare using [[web: |
| - | * Add the desired publicly accessible subdomains | + | * For each domain |
| - | * Navigate to the domain > '' | + | * Navigate to each domain > '' |
| - | * For each subdomain: | + | * Add wildcard CNAME record: |
| - | * '' | + | * '' |
| - | * '' | + | * '' |
| - | * '' | + | * '' |
| - | * '' | + | * '' |
| - | * '' | + | * '' |
| - | * '' | + | * '' |
| - | * Repeat | + | * Add a ' |
| + | * If not using a wildcard CNAME record, add a CNAME record for the desired subdomain as above | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| Install a base installation of Photon OS with the following changes: | Install a base installation of Photon OS with the following changes: | ||
| Line 31: | Line 39: | ||
| sed -i " | sed -i " | ||
| reboot | reboot | ||
| - | |||
| - | # Download Caddy | ||
| - | tdnf install tar | ||
| - | mkdir / | ||
| - | # Copy the link for the " | ||
| - | curl -L -o / | ||
| - | tar -xzf caddy.tar.gz -C / | ||
| - | mv / | ||
| - | rm / | ||
| # Add the caddy group and user | # Add the caddy group and user | ||
| Line 51: | Line 50: | ||
| caddy | caddy | ||
| - | # Config file and html pages | ||
| cd /usr/bin | cd /usr/bin | ||
| + | |||
| + | # Download Caddy | ||
| + | curl -L -o " | ||
| + | chmod 755 caddy | ||
| + | |||
| + | # Config file and html pages | ||
| curl -L -o " | curl -L -o " | ||
| chmod u+x fetch | chmod u+x fetch | ||
| - | # Generate a GitHub Personal Access Token at https:// | + | |
| - | fetch --repo=" | + | # Generate a GitHub Personal Access Token at https:// |
| + | # Enter the key when this command asks | ||
| + | read -rp "Enter github api token: " token && echo " | ||
| + | # Reload the shell so it exports the tokens in this session | ||
| + | exec $SHELL | ||
| + | |||
| + | fetch --repo=" | ||
| chmod -R a=r,u+w,a+X /etc/caddy | chmod -R a=r,u+w,a+X /etc/caddy | ||
| - | # Setup startup, and run | + | # Setup caddy startup |
| curl -L -o / | curl -L -o / | ||
| systemctl daemon-reload | systemctl daemon-reload | ||
| - | systemctl | + | |
| - | systemctl | + | # Get a DNS API token from https:// |
| + | # Edit zone DNS > Use template: | ||
| + | # | ||
| + | # Add a Permissions entry for: Zone.Zone: | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # Set up Google OAuth 2.0: | ||
| + | # Go to: [[https:// | ||
| + | # | ||
| + | # | ||
| + | |||
| + | systemctl | ||
| + | # Paste in the following lines with their respective keys filled in: | ||
| + | [Service] | ||
| + | Environment=" | ||
| + | Environment=" | ||
| + | Environment=" | ||
| + | # Then save and exit the file with: ESC, :wq | ||
| + | |||
| + | # Enable and run the Caddy service | ||
| + | systemctl | ||
| </ | </ | ||
| Line 80: | Line 111: | ||
| systemctl reload caddy | systemctl reload caddy | ||
| </ | </ | ||
| + | |||
| + | Edit the Caddyfile at [[https:// | ||
| + | |||
| + | Services that require setting Trusted Proxies: | ||
| + | * [[esxi: | ||
| + | * [[home:Home Assistant]] | ||
| + | * [[esxi:AMP Game Server]] | ||
| @No_Backup | @No_Backup | ||
| Line 86: | Line 124: | ||
| {{page> | {{page> | ||
| + | Check for updates and changelogs from: [[https:// | ||
| <code bash> | <code bash> | ||
| - | # Update Caddy | + | # Check the current running version |
| caddy version | caddy version | ||
| - | # Compare with the version from https:// | + | |
| - | curl -L -o / | + | # Update Caddy |
| - | tar -xzf caddy.tar.gz -C / | + | caddy update |
| - | mv / | + | chmod 755 /usr/bin/caddy |
| - | rm / | + | |
| systemctl reload caddy | systemctl reload caddy | ||
| - | # Update just config | + | # Once a year generate |
| - | # Generate | + | # Enter the key when this command asks |
| - | fetch --repo=" | + | read -rp "Enter api token: " token && echo " |
| + | # Reload the shell so it exports the tokens in this session | ||
| + | exec $SHELL | ||
| + | |||
| + | # Update just the Caddy config | ||
| + | fetch --repo=" | ||
| # Update Config and HTML | # Update Config and HTML | ||
| # Remove old folder if any files have been deleted/ | # Remove old folder if any files have been deleted/ | ||
| rm -r /etc/caddy | rm -r /etc/caddy | ||
| - | # Generate a GitHub Personal Access Token at https:// | + | fetch --repo=" |
| - | fetch --repo=" | + | |
| chmod -R a=r,u+w,a+X /etc/caddy | chmod -R a=r,u+w,a+X /etc/caddy | ||