Konfigurasi Caddy Server dan PHP-FPM di Ubuntu Linux

Konfigurasi Caddy Server dan PHP-FPM di Ubuntu Linux - Caddy adalah webserver open source yang cepat dan gampang digunakan. Selain itu, Caddy Server otomatis menjalankan situs via HTTPS saat digunakan, sehingga tidak perlu repot-repot konfigurasi SSL lagi. Sebagai catatan, SSL yang dipasang adalah Lets Encrypt.

Fitur Caddy Server

Basic Features

  • THE CADDYFILE An easy, intuitive way to configure your site. It's not scripting, and not hard to memorize. Rolls off the fingers. You'll really like it.
  • STATIC FILES By default, Caddy will serve static files in the current working directory. It's so brilliantly simple and works fast.
  • DYNAMIC SITES Caddy can also be used to serve dynamic sites with templates, proxying, FastCGI, and by the use of plugins.
  • COMMAND LINE INTERFACE Customize how Caddy runs with its simple, cross-platform command line interface; especially great for quick, one-off server instances.
  • PLUGINS Caddy can be extended with plugins. All server types, directives, DNS providers, and more features are plugins! They're easy to write and get compiled in directly.
  • MULTI-CORE When the going gets tough, Caddy gets going on more CPUs. Go's scheduler understands Go code, and goroutines are more lightweight than system threads. So yeah, it's fast.
  • EMBEDDABLE Writing another program or web service that could use a powerful web server or reverse proxy? Caddy can be used like a library in your Go program.
  • RUN COMMANDS Caddy can be configured to run system commands at startup and shutdown. Useful when your site requires other processes running.
  • CADDYFILE VALIDATION Given a command line flag, Caddy will parse and verify your Caddyfile without actually running it.
  • PROCESS LOG Caddy can write a log of all its significant events, especially errors. Log to a file, stdout/stderr, or a local or remote system log!
  • LOG ROLLING When log files get large, Caddy will automatically rotate them to conserve disk space.

Deployment

  • STATIC BINARY Caddy is a single executable file with no dependencies, not even libc. Literally just needs some metal and a kernel. Put Caddy in your PATH and run it. Done.
  • CROSS-PLATFORM Windows, macOS, Linux, BSD, Android, Solaris, 32-bit, x64, ARM, mips64... you name it: Caddy probably compiles for it.
  • GRACEFUL RELOADS After making config changes, use signal USR1 to reload Caddy gracefully with zero downtime on Unix systems.
  • GRACEFUL UPGRADES Replace the binary and upgrade it by signaling Caddy with USR2. Caddy will restart with zero downtime on Unix systems.
  • CUSTOM BUILDS When you download Caddy from our website, choose the plugins you want to include, and get a custom build in seconds made just for you.
  • SIGNED DOWNLOADS Each download from the Caddy website—even custom builds—are cryptographically signed which you can use to check their integrity.
  • PIDFILE Caddy can write a process ID (PID) file to disk so you can more easily keep track of it in automated/headless environments.
  • CONTAINERS Caddy runs well in bare Docker images and is even available for download as a Docker image.
  • HOMEBREW Caddy is already so easy to install, but it's even easier on Mac with brew install caddy.

Install dan Konfigurasi Dasar di Ubuntu
Oke sekarang kita coba untuk install Caddy Server di Ubuntu.
curl https://getcaddy.com | bash
Lalu kita install juga PHP-FPM.
sudo apt install -y php-fpm php-cli php-mysql php-gd curl
Selanjutnya kita buat direktori webserver untuk domain kita.
mkdir ~/webserver/zafkiel.net
Buat file index.php dengan isi
<?php
echo " This awesome website is powered by Caddy Server";
?>
Oke, sekarang kita buat Caddyfile nya. Jangan dibuat di direktori web server ya. Tapi di direktori lain. Sebagai contoh, disini saya buat filenya di direktori ~/webserver
nano Caddyfile
isinya
caddy.zafkiel.net # Your site's address
root /home/yuyudhn/webserver/zafkiel.net # root path
index index.php # index filename
header / {
# Enable HTTP Strict Transport Security (HSTS) to force clients to always
# connect via HTTPS (do not use if only testing)
Strict-Transport-Security "max-age=31536000;"
# Enable cross-site filter (XSS) and tell browser to block detected attacks
X-XSS-Protection "1; mode=block"
# Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
X-Content-Type-Options "nosniff"
# Disallow the site to be rendered within a frame (clickjacking protection)
X-Frame-Options "DENY"
}

errors error.log { # Error log
404 error-404.html # Custom error page
}

# PHP backend
fastcgi / /run/php/php7.1-fpm.sock php

Sesuaikan sendiri versi php-fpm yang kalian gunakan. Sekarang jalankan perintah caddy di direktori tempat Caddyfile berada.
cd ~/webserver
caddy
Contoh output
Activating privacy features... done.
https://caddy.zafkiel.net
http://caddy.zafkiel.net


Cek di browser:

Informasi Header

Catatan:
Di tutorial ini saya menunjukkan bagaimana cara mengkonfigurasi fastcgi jika kalian menggunakan backend PHP. Jika kalian tidak membutuhkannya, tidak perlu diinstall.
Untuk konfigurasi lain, bisa dibaca di situs caddyserver
  • https://caddyserver.com/docs
Oke mungkin sekian tutorial kali ini, jika ada yang kurang jelas silahkan ditanyakan.

Posting Komentar untuk "Konfigurasi Caddy Server dan PHP-FPM di Ubuntu Linux"