Site icon CentLinux

Install Caddy Web Server on Rocky Linux 9

Share on Social Media

Learn how to effortlessly install Caddy Web Server on Rocky Linux 9 with our step-by-step guide. Enhance your web hosting experience with Caddy’s modern features and robust performance capabilities. #centlinux #linux #webserver

What is Caddy Server?:

Caddy is an open-source web server and reverse proxy server written in the Go programming language. It’s known for its simplicity, speed, and its ability to automatically configure and manage SSL certificates for secure HTTPS connections. Caddy is designed to be easy to use, making it accessible to both beginners and experienced developers. It’s often used for hosting websites, APIs, and web applications, and it’s particularly popular in the DevOps and cloud-native communities for its lightweight and efficient design.

Features in Caddy Web Server:

Caddy is known for its simplicity and powerful features, making it a popular choice for web server and reverse proxy needs. Some of its notable features include:

Automatic HTTPS: Caddy is renowned for its seamless integration with Let’s Encrypt, allowing it to automatically obtain and manage SSL certificates for secure HTTPS connections. This is a standout feature that simplifies the process of securing websites.

HTTP/2 Support: Caddy supports HTTP/2, the latest version of the HTTP protocol. This enables faster and more efficient communication between the web server and clients.

Virtual Hosting: It allows you to host multiple websites or domains on a single instance of Caddy. This is crucial for individuals or organizations managing multiple web properties.

Reverse Proxy: Caddy can be configured as a reverse proxy, enabling it to forward requests to other servers or services. This is useful for load balancing, caching, and handling complex routing scenarios.

FastCGI Support: It can handle FastCGI requests, making it compatible with applications and frameworks that rely on this protocol.

Static File Serving: Caddy is efficient at serving static files, making it a suitable choice for hosting simple websites or web applications.

Easy Configuration (Caddyfile): Caddy uses a Caddyfile configuration format that is known for its simplicity and readability. This format makes it easy for both beginners and experienced users to set up and manage the server.

Modular Architecture: Caddy’s design is modular, allowing users to enable or disable features based on their specific requirements. It also supports the use of plugins to extend its functionality.

Middleware Support: Caddy supports various middleware modules, which can be used to add functionality like rewriting URLs, applying access controls, and more.

Metrics and Monitoring: It provides basic metrics about request/response rates and latencies, which can be useful for monitoring server performance.

IPv6 Support: Caddy is compatible with IPv6, ensuring that it can handle traffic from devices and networks using this newer internet protocol.

Graceful Restart and Zero Downtime: Caddy allows for graceful restarts, meaning it can reload configurations and apply changes without interrupting ongoing requests.

Web-based Administration Interface (Caddy API): Caddy provides a simple web-based interface for monitoring server status, reloading configurations, and more.

JSON Configuration Option: While the Caddyfile format is preferred for its readability, Caddy also allows advanced users to configure it using JSON.

These features collectively make Caddy a powerful and user-friendly choice for web server needs, particularly for those looking for a streamlined experience with robust security features.

Read Also: How to install Caddy Server on CentOS 7

Caddy vs Apache:

Caddy and Apache are both web servers, but they have significant differences. Here’s a comparison:

Ease of Configuration:

Caddy: Known for its simplicity and user-friendly configuration. It uses a Caddyfile format that is easy to understand and requires minimal setup for basic use. Automatic SSL certificate management is a key feature.

Apache: Known for its powerful but sometimes complex configuration files, which use a syntax that might be less intuitive for beginners.

Automatic HTTPS:

Caddy: It’s a standout feature. Caddy automatically configures and manages SSL certificates using Let’s Encrypt, providing secure HTTPS connections by default.

Apache: While it supports HTTPS, setting up and managing SSL certificates usually requires additional steps and tools.

Performance:

Caddy: Written in Go, it’s known for its speed and efficiency, making it suitable for high-performance use cases. It’s particularly adept at serving static files.

Apache: It’s powerful and feature-rich but can be slightly slower compared to Caddy, especially when serving static content.

Modules and Extensions:

Caddy: Offers a modular architecture, allowing users to enable or disable features as needed. There’s an active community creating various plugins.

Apache: Known for its extensive module system. There’s a vast library of modules available for various functionalities, giving it a high level of flexibility.

Community and Ecosystem:

Caddy: While growing, it has a smaller community compared to Apache. This means that the available resources, tutorials, and third-party integrations may be more limited.

Apache: One of the oldest and most widely used web servers. It has a massive community with a wealth of documentation, tutorials, and support forums.

Use Cases:

Caddy: Particularly popular in situations where ease of use, automatic HTTPS, and quick deployment are crucial. It’s often used for static sites, APIs, and microservices.

Apache: Widely used across various types of web applications and is well-suited for complex setups and environments with a diverse range of requirements.

Operating System Support:

Caddy: Supports a variety of operating systems, including Linux, macOS, Windows, and BSD variants.

Apache: Compatible with an even broader range of operating systems, including many UNIX and UNIX-like systems.

Ultimately, the choice between Caddy and Apache will depend on your specific requirements, familiarity with the servers, and the type of projects you’re working on. Caddy’s simplicity and built-in features make it a strong choice for many modern web development needs, while Apache’s extensive feature set and widespread use continue to make it a staple in the web server landscape.

Environment Specification:

We are using a minimal Rocky Linux 9 virtual machine with following specifications.

Read Also: Install MinIO Object Storage on Rocky Linux 8

Initial Configurations:

Login to your Rocky Linux server as root user by means of a ssh client.

Set a hostname and Local DNS resolution for your Linux machine.

# hostnamectl set-hostname caddy-01.centlinux.com
# echo "192.168.18.83 caddy-01 caddy-01.centlinux.com" >> /etc/hosts

Execute following command at Linux bash, to update software packages in your operating system.

# dnf update -y

If the above command updates your Linux Kernel, then you should reboot before installing Caddy web server.

# reboot

After reboot, check the Linux OS and Linux Kernel versions.

# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.2 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.2"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.2 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.2"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.2"

# uname -r
5.14.0-284.30.1.el9_2.x86_64

Install Caddy Web Server on Linux:

Execute following command to install COPR plugin for dnf command.

# dnf install -y 'dnf-command(copr)'

Enable Caddy repository by using following command.

# dnf copr enable @caddy/caddy
Enabling a Copr repository. Please note that this repository is not part
of the main distribution, and quality may vary.

The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://docs.pagure.org/copr.copr/user_documentation.html#what-i-can-build-in-copr>,
and packages are not held to any quality or security level.

Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.

Do you really want to enable copr.fedorainfracloud.org/@caddy/caddy? [y/N]: y
Repository successfully enabled.

Now, you can install Caddy server on Linux.

# dnf install -y caddy

After successful installation, disable the Caddy repository.

# dnf copr disable @caddy/caddy
Repository successfully disabled.

Verify the version of Caddy server.

# caddy version
v2.7.4 h1:J8nisjdOxnYHXlorUKXY75Gr6iBfudfoGhrJ8t7/flI=

You can check, we have installed caddy 2.7, which is the latest version of caddy web server at the time of this writing.

Enable and start Caddy server.

# systemctl enable --now caddy
Created symlink /etc/systemd/system/multi-user.target.wants/caddy.service → /usr/lib/systemd/system/caddy.service.

Configure Linux Firewall:

Like Apache, Nginx or any other web server, Caddy Server also user default service ports i.e.

  1. port 80 for http
  2. port 443 for https

Therefore, you must allow these ports in your Linux firewall, to make your websites accessible from the network.

# firewall-cmd --permanent --add-service={http,https}
success

# firewall-cmd --reload
success

Accessing Caddy Web Service:

Open URL http://caddy-01.centlinux.com in a web browser.

Install Caddy Web Server Message

Video to install Caddy Web Server on Linux:

Read Also: How to configure FastCGI Server on CentOS 7

Final Thoughts

As you conclude the process to install Caddy Web Server on Rocky Linux 9, you’ve embarked on a journey toward enhancing your web hosting capabilities. Caddy’s user-friendly interface, modern features, and robust performance make it a valuable asset for any website or application. By following the steps outlined in this guide, you’ve gained the knowledge and skills to deploy Caddy effectively on your Rocky Linux server, empowering you to deliver faster, more secure, and more reliable web services to your users. Now, armed with Caddy’s capabilities, you’re ready to take your web hosting experience to the next level and achieve your online objectives with confidence.

Exit mobile version