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/05 17:23] derek |
esxi:caddy_server [2024/09/22 19:51] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
=====Caddy Server===== | =====Caddy Server===== | ||
- | FIXME: Explain the page/ | + | Caddy is a reverse proxy and lightweight webserver that automatically acquires and uses https certificates. |
- | Using Caddy to host the list, Love Letter counter, and reverse proxy many internal sites | + | Caddy is used here to host a list of links, the Love Letter counter, and reverse proxy many internal sites. |
====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 12: | 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 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 39: | 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: | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # Edit zone DNS > Use template: | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # 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=" | ||
+ | Environment=" | ||
+ | # Then save and exit the file with: ESC, :wq | ||
+ | |||
+ | # 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 67: | 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 | ||
====Update==== | ====Update==== | ||
{{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/ | ||
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 | ||
+ | |||
+ | # Test updated Caddyfile | ||
+ | caddy validate --config / | ||
# Use updated config file | # Use updated config file |