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 16:04] derek |
esxi:caddy_server [2024/09/22 19:51] (current) |
||
---|---|---|---|
Line 5: | Line 5: | ||
====Setup==== | ====Setup==== | ||
* Set up DNS with Cloudflare using [[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 46: | Line 54: | ||
# Download Caddy | # Download Caddy | ||
curl -L -o " | curl -L -o " | ||
- | chmod u+x caddy | + | chmod 755 caddy |
# Config file and html pages | # 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 | ||
+ | |||
+ | # Get a DNS API token from https:// | ||
+ | # Edit zone DNS > Use template: | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # Edit zone DNS > Use template: | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # Set up Google OAuth 2.0: | ||
+ | # Go to: [[https:// | ||
+ | # | ||
+ | # | ||
+ | |||
+ | systemctl edit caddy | ||
+ | # Paste in the following lines with their respective keys filled in: | ||
+ | [Service] | ||
+ | Environment=" | ||
+ | Environment=" | ||
+ | Environment=" | ||
+ | Environment=" | ||
+ | # Then save and exit the file with: ESC, :wq | ||
+ | |||
+ | # Enable and run the Caddy service | ||
systemctl enable --now caddy | systemctl enable --now caddy | ||
</ | </ | ||
Line 75: | Line 115: | ||
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 88: | Line 135: | ||
# Update Caddy | # Update Caddy | ||
caddy update | caddy update | ||
+ | chmod 755 / | ||
systemctl reload caddy | 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 | # Update just the Caddy config | ||
- | # Generate a GitHub Personal Access Token at https:// | + | fetch --repo=" |
- | 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 | ||