This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
esxi:caddy_server [2020/07/03 18:47] derek |
esxi:caddy_server [2025/12/25 09:41] (current) derek |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| =====Caddy Server===== | =====Caddy Server===== | ||
| - | FIXME: Explain | + | Caddy is a reverse proxy and lightweight webserver that automatically acquires and uses https certificates. |
| + | Caddy is used here to host a list of links, | ||
| ====Setup==== | ====Setup==== | ||
| - | First, install | + | * Set up DNS with Cloudflare using [[web: |
| + | * For each domain used: | ||
| + | * Navigate to each domain > '' | ||
| + | * Add wildcard CNAME record: | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * Add a ' | ||
| + | * If not using a wildcard CNAME record, add a CNAME record for the desired subdomain as above | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | Install | ||
| * Hostname: '' | * Hostname: '' | ||
| * CPU: 1 | * CPU: 1 | ||
| Line 11: | Line 32: | ||
| ===Install Caddy Server:=== | ===Install Caddy Server:=== | ||
| - | * Add a port forwarding rule in your router for tcp, port '' | + | * Add a port forwarding rule in your router for tcp, port: '' |
| * Using an SSH client, connect to < | * Using an SSH client, connect to < | ||
| Line 19: | Line 40: | ||
| reboot | reboot | ||
| - | # Download Caddy | + | # Add the caddy group and user |
| - | tdnf install tar | + | |
| - | mkdir / | + | |
| - | cd / | + | |
| - | # Copy the link for the " | + | |
| - | curl -OL "< | + | |
| - | tar -xzf < | + | |
| - | mv caddy /usr/bin/ | + | |
| - | cd ~ | + | |
| - | rm -r / | + | |
| - | + | ||
| - | # Add caddy group/user | + | |
| groupadd --system caddy | groupadd --system caddy | ||
| useradd --system \ | useradd --system \ | ||
| Line 40: | Line 50: | ||
| caddy | caddy | ||
| - | # Setup startup | + | cd /usr/bin |
| - | cd / | + | |
| - | curl -OL " | + | # Download Caddy |
| + | curl -L -o " | ||
| + | chmod 755 caddy | ||
| + | |||
| + | # Config file and html pages | ||
| + | curl -L -o " | ||
| + | chmod u+x fetch | ||
| + | |||
| + | # 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 / | ||
| + | |||
| + | # Setup caddy startup | ||
| + | curl -L -o / | ||
| systemctl daemon-reload | systemctl daemon-reload | ||
| - | systemctl enable caddy | ||
| - | # Config file | + | # Get a DNS API token from https:// |
| - | mkdir /etc/caddy | + | # Edit zone DNS > Use template: |
| - | chmod 755 /etc/caddy | + | # |
| - | cd /etc/caddy | + | # Add a Permissions entry for: Zone.Zone: |
| - | # FIXME: Download Caddyfile | + | # |
| - | chmod 644 Caddyfile | + | # Save/keep open the API token |
| + | |||
| + | # Set up Google OAuth 2.0: | ||
| + | # Go to: [[https:// | ||
| + | # | ||
| + | # Save/keep open the Client ID/Secret | ||
| + | |||
| + | systemctl edit caddy | ||
| + | # Paste in the following lines with their respective keys filled in: | ||
| + | [Service] | ||
| + | Environment=" | ||
| + | Environment=" | ||
| + | Environment=" | ||
| + | # Then save and exit the file with: ESC, :wq | ||
| - | systemctl | + | # Enable and run the Caddy service |
| + | systemctl | ||
| </ | </ | ||
| * Edit the VM note and append the following: | * Edit the VM note and append the following: | ||
| < | < | ||
| + | 80,443/tcp Http,Https Caddy | ||
| </ | </ | ||
| * Save a snapshot called '' | * Save a snapshot called '' | ||
| Line 69: | 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 | ||
| ====Update==== | ====Update==== | ||
| {{page> | {{page> | ||
| - | * FIXME: Describe update Process | + | Check for updates and changelogs from: [[https:// |
| - | * Include in update all page using '' | + | |
| <code bash> | <code bash> | ||
| - | # Copy the link for the "caddy_2.x.x_linux_amd64.tar.gz" | + | # Check the current running version |
| - | curl -OL "< | + | caddy version |
| - | tar -xzf < | + | |
| - | mv caddy /usr/bin/ | + | # Update Caddy |
| - | cd ~ | + | caddy update |
| - | rm -r /tmp/caddy | + | chmod 755 / |
| + | systemctl reload caddy | ||
| + | |||
| + | # Once a year generate a GitHub Personal Access Token at https:// | ||
| + | # Enter the key when this command asks | ||
| + | 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 | ||
| + | # Remove old folder if any files have been deleted/moved/ | ||
| + | rm -r / | ||
| + | fetch --repo="https:// | ||
| + | chmod -R a=r, | ||
| + | |||
| + | # Test updated Caddyfile | ||
| + | caddy validate --config / | ||
| + | |||
| + | # Use updated config file | ||
| systemctl reload caddy | systemctl reload caddy | ||
| </ | </ | ||