DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk11 min

How to Host a Website with Caddy on a Linux VPS

A practical guide to hosting static files or a local application with Caddy on a Linux VPS, from DNS and firewall setup through automatic HTTPS and reverse-proxy troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To host a website with Caddy, point your domain’s DNS records at a Linux VPS, open TCP ports 80 and 443, install Caddy from the official package for your distribution, and place a site block in /etc/caddy/Caddyfile. Use file_server for static files or reverse_proxy to publish an application running locally. Once the public hostname resolves to the VPS, Caddy obtains and renews a publicly trusted HTTPS certificate and redirects HTTP traffic to HTTPS automatically.

What you need before installing Caddy

A successful deployment depends on four pieces being ready at the same time: a reachable VPS, a domain name you control, correct DNS, and internet access to Caddy’s listening ports. If any one is missing, the configuration can look correct while browsers or certificate issuance still fail.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A Linux VPS with a public interface

Choose a VPS that has a public IPv4 address, an IPv6 address if you intend to publish an AAAA record, or both. The server must be reachable from the internet rather than limited to a private network. You also need administrative access so you can install a system service, edit the Caddyfile, and configure host and provider firewalls.

A registered domain

Use a hostname that you control, such as example.com or www.example.com. Caddy’s normal public certificate flow is designed for a public hostname. A local name such as localhost is treated differently: Caddy can serve a locally trusted or self-signed certificate, but browsers will not regard it as a publicly trusted certificate.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

DNS records aimed at the VPS

Create an A record for the VPS’s IPv4 address. If you are serving IPv6, create an AAAA record for the VPS’s IPv6 address as well. Check the records with an authoritative DNS lookup before starting Caddy. The answer must show the address of this VPS, not an old server, a parking page, or another provider.

Internet access to ports 80 and 443

Allow inbound TCP traffic on port 80 for HTTP and port 443 for HTTPS in two places: the VPS provider’s security group or network firewall, and the Linux host firewall. Both ports need to be publicly reachable for the ordinary ACME validation flow and for visitors to reach the site. Opening a port in only one of those layers is not enough.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Caddy as a production service

Use the official package for your Linux distribution when one is available. The packaged installation integrates Caddy with systemd, gives the service a predictable configuration location, and is the recommended production path. Running the binary manually can be useful for a temporary test, but it leaves process supervision, startup after reboot, and low-port privileges for you to manage.

Use the distribution package

  1. Log in to the VPS with an administrative account or an account that can use sudo.
  2. Follow Caddy’s official installation instructions for your distribution and install the official package rather than an unrelated third-party build.
  3. Confirm that the package created a systemd service. The packaged service convention uses /etc/caddy/Caddyfile as the main configuration file.
  4. Keep the service enabled so it starts after a reboot, then start it after you have a valid site configuration.

The exact package command differs by distribution, so use the command for the Linux release running on your VPS. Do not copy an installation command for a different distribution’s package manager.

Understand the service account and ports

The system service normally runs with the privileges needed to bind the web ports while keeping the application itself separate. If you instead start Caddy manually as an unprivileged user, binding ports below 1024 can fail. Caddy’s reverse-proxy documentation describes either running with suitable privileges or granting the binary the cap_net_bind_service capability. For a production site, the packaged systemd service avoids that common setup mistake.

Choose static hosting or reverse proxying

Caddy can serve files itself or forward each request to an application process. The choice changes what you manage on the VPS.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Hosting model What Caddy does What you operate When it fits
Static file server Reads files from a directory and returns them directly File ownership, uploads or deployments, and the directory contents HTML, CSS, JavaScript, images, downloads, and generated sites
Reverse proxy Accepts the public request and forwards it to one or more upstreams The application process, its local port, process restarts, and application health Web frameworks, APIs, dashboards, and any server-rendered application

In both models, the public hostname and HTTPS handling stay at Caddy. With a reverse proxy, the application can remain on a loopback address and does not need its own public firewall rule. Caddy’s reverse_proxy directive can later address multiple upstreams, load balancing, active and passive health checks, request manipulation, and buffering when the deployment grows.

Publish a static website

This is the shortest configuration when the site is a directory of files. The example below publishes /var/www/example at example.com.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

1. Place the site files

Create the document directory and copy your built site into it. The Caddy service account must be able to traverse the parent directories and read the files. If the service cannot read a file, the browser may receive an error even though DNS and HTTPS are working.

sudo mkdir -p /var/www/example
# Copy your index.html, CSS, JavaScript and assets into /var/www/example

2. Write the Caddyfile site block

Edit /etc/caddy/Caddyfile and add this block:

example.com {
    root * /var/www/example
    file_server
}

The first line is the hostname. root selects the directory, and file_server tells Caddy to serve its contents. Keep the hostname exactly as it appears in DNS. If you also want a www hostname, create a separate site address or include it in the site address according to the naming pattern you intend to publish.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Validate and reload

Check the configuration before applying it:

sudo caddy validate --config /etc/caddy/Caddyfile

A successful validation means Caddy can parse the file; it does not prove that DNS, the firewall, or the files themselves are correct. Reload the running service after validation:

sudo systemctl reload caddy

Reloading applies the new site without stopping the service. If the packaged service is not running yet, start it through systemd after validation.

4. Test the hostname

Open the hostname in a browser and confirm that the expected index page and assets load. Test the HTTPS address rather than only the HTTP address; the normal automatic-HTTPS behavior should redirect an HTTP request to HTTPS once certificate issuance succeeds.

Expose an application with a reverse proxy

For an application, let the application listen on a local address and let Caddy own the public hostname and ports. A minimal site block is only two lines inside the hostname block:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
example.com {
    reverse_proxy 127.0.0.1:9000
}

This forwards requests for example.com to a process listening on port 9000 on the same VPS. The application can remain private on loopback; visitors connect to Caddy, not directly to port 9000.

1. Start the backend first

Run your application on the address and port named in the proxy target. Confirm that it is actually listening there before troubleshooting Caddy. A backend bound to a different port, a different interface, or a Unix socket will not answer a proxy target of 127.0.0.1:9000.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

2. Keep the backend port private

Bind the application to loopback when it does not need direct public access. This reduces the number of exposed services and leaves TLS, redirects, and the public entry point in one place. Do not open the backend port in the provider firewall merely because Caddy needs to reach it locally.

3. Configure and apply the proxy

Add the block to /etc/caddy/Caddyfile, validate it, and reload Caddy:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo caddy validate --config /etc/caddy/Caddyfile
sudo systemctl reload caddy

For a quick, disposable deployment, Caddy also provides the equivalent command-line form:

caddy reverse-proxy --from example.com --to localhost:9000

The command-line form is useful for proving that an upstream works, while the systemd-managed Caddyfile is easier to keep across reboots and configuration changes.

4. Move from one upstream to several

When you run multiple application instances, list multiple upstreams in the reverse_proxy configuration. Caddy supports load balancing, active health checks, passive health checks, request manipulation, and buffering. Add those features when you have a real availability or traffic requirement; a single local process does not need the complexity of a multi-upstream design.

How Caddy obtains and renews HTTPS certificates

Caddy enables HTTPS by default when a public hostname is present in the configuration. It requests a certificate from a public ACME certificate authority, installs the certificate for the hostname, and manages renewal. It also inserts an HTTP-to-HTTPS redirect, so visitors who type an HTTP URL are sent to the HTTPS URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Conditions for a publicly trusted certificate

  • The hostname’s public DNS must resolve to this VPS.
  • TCP port 80 must be reachable from the internet for the normal HTTP validation path.
  • TCP port 443 must be reachable so browsers can complete HTTPS connections after issuance.
  • Caddy must be running with the site address present in its active configuration.

Certificate issuance can fail when a stale A or AAAA record sends the validation request to another machine, when a provider security group blocks the traffic, or when the Linux firewall drops it. Fix the underlying reachability problem and reload or retry the Caddy configuration rather than replacing the certificate settings with a self-signed certificate for a public site.

Public names versus localhost

A public hostname can receive a publicly trusted certificate through the normal ACME flow. A localhost certificate is self-signed or locally trusted instead, which is appropriate for development but produces a browser warning on an ordinary visitor’s device. Do not use a localhost certificate as a substitute for correcting public DNS and port access.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Point the domain at Caddy in the right order

The order matters because Caddy’s certificate request follows the hostname in the site block. Complete the following sequence before judging the HTTPS result:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Record the VPS’s public IPv4 address and, if used, its IPv6 address.
  2. Create or update the domain’s A and AAAA records with those addresses.
  3. Query authoritative DNS and wait until the responses show the VPS rather than the previous destination.
  4. Permit TCP 80 and 443 at the provider firewall and on the Linux host.
  5. Install and start the packaged Caddy service with the hostname configured.
  6. Watch the first browser request and correct whichever layer still points elsewhere or blocks the connection.

DNS changes can be visible from one resolver before another. The decisive check is an authoritative lookup for the hostname, followed by a connection test from outside the VPS network. Testing only from the server itself can hide a provider firewall or public-routing problem.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Validate, reload, and maintain configuration safely

Validate before every change

Use Caddy’s validation command against the file actually used by the service:

sudo caddy validate --config /etc/caddy/Caddyfile

This catches syntax and adaptation errors before they replace a working configuration. Keep the previous working copy available so you can restore it if a larger edit introduces an unintended site or proxy rule.

Reload instead of stopping the service

After validation, reload the service so existing connections have the best chance of completing while the new configuration is applied:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo systemctl reload caddy

A full restart is not a substitute for fixing a failed validation. If Caddy cannot load the new file, the service may continue with its previous configuration or fail to start, depending on when the error occurs.

Keep application and proxy changes coordinated

For a reverse proxy, change the backend’s listening address and the Caddy upstream target as one deployment. A configuration that points to a port before the application is listening creates an upstream connection error. Conversely, changing only the application port leaves Caddy forwarding to the old location.

Troubleshoot by symptom

The certificate is issued for the wrong server or issuance fails

Check the A and AAAA records first. One old AAAA record can send IPv6 validation to a different host even when the A record is correct. Then inspect both firewall layers and confirm that ports 80 and 443 are directed to this VPS. Do not assume that a successful DNS lookup from inside the VPS proves that the public path is open.

The browser cannot connect at all

Confirm that the Caddy service is running, that the hostname appears in the active Caddyfile, and that the provider security group allows TCP 80 and 443. A host firewall rule can still block traffic after the provider firewall has been opened. If the site is intended to be HTTPS-only, test both the HTTP URL and the HTTPS URL so you can distinguish a missing redirect from a completely unreachable service.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Caddy reports an upstream connection error

This indicates that the proxy target did not accept the connection. Verify the application’s actual listening address and port, then compare them character for character with the reverse_proxy target. Check whether the process stopped, whether it is bound only to a different interface, and whether a local firewall or socket permission prevents the Caddy service account from reaching it.

Manual Caddy startup cannot bind the web ports

Ports 80 and 443 are low-numbered ports. A manually launched, unprivileged Caddy process may lack permission to bind them. Run it with suitable privileges or grant the binary cap_net_bind_service as documented by Caddy. The simpler production answer is to use the official package and its systemd service.

HTTPS works on the server but warns in a browser

Check which hostname the browser is using. A certificate for the public hostname will not make localhost trusted, and a localhost certificate is not publicly trusted. Use the configured public name for an internet-facing site and reserve localhost certificates for local development.

Operational patterns that scale beyond the first site

Separate site blocks by hostname

Give each public hostname its own site block, with its own root directory or upstream target. This makes it clear which files and application receive a request and limits accidental changes to unrelated sites. Keep the service’s single Caddyfile as the source of truth used by systemd.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Caddy as the stable public boundary

Applications can change frameworks, ports, or process managers without changing the public DNS name. Caddy remains responsible for certificate lifecycle, HTTP-to-HTTPS redirects, and forwarding. This separation also means the backend does not have to implement public certificate renewal itself.

Add health checks only when they solve a real failure mode

With one upstream, a health-check policy adds little value. With multiple instances, active and passive checks can keep failed processes from receiving traffic, while load balancing distributes requests. Buffering and request manipulation can help specific applications, but each option should be introduced with a clear behavior you need to control.

Deployment checklist

  • VPS has a public interface and administrative access.
  • Domain is registered and under your control.
  • A record points to the VPS IPv4 address.
  • AAAA record, if present, points to the VPS IPv6 address.
  • Authoritative DNS lookup returns the intended addresses.
  • Provider firewall allows inbound TCP 80 and 443.
  • Linux host firewall allows inbound TCP 80 and 443.
  • Official Caddy package is installed and managed by systemd.
  • /etc/caddy/Caddyfile contains the correct hostname.
  • Static sites have a readable root and file_server, or applications have a reachable reverse_proxy target.
  • Configuration passes caddy validate --config /etc/caddy/Caddyfile.
  • Caddy is reloaded after the validated change.
  • Browser test confirms the expected content over HTTPS and the HTTP-to-HTTPS redirect.

Useful quick-start commands

For a static site, the official command-line shortcut is:

caddy file-server --domain example.com

For an application listening on port 9000, the corresponding shortcut is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
caddy reverse-proxy --from example.com --to localhost:9000

These commands demonstrate the two hosting models. For a persistent VPS deployment, place the equivalent directives in /etc/caddy/Caddyfile and run Caddy through the packaged systemd service so the configuration survives logouts and reboots.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.