Web server Rookie Caddy installation deployment

Source: Internet
Author: User
Tags quic

Caddy Introduction

Caddy is a Go language written, open source good Web server. It has some of the following features:

Simple configuration: The operation of the Caddy server can be configured through the Caddyfile configuration file.
Automatic https: It can automatically request the Let's Encrypt domain name certificate, and configure it, automatically updated periodically, and free of charge.
HTTP/2: Default support HTTP/2 (supported by Go standard library)
Virtual Hosting: Caddy supports TLS's SNI. You can deploy multiple different domain name services on the same host with a single public IP. You can configure different certificates and keys for different domains of caddy services.
Quic Support: Caddy supports the QUIC protocol experimentally for better performance.
Good scalability: So Caddy is easy to customize for your needs.
Rich plugins: Rich plug-ins, to solve business needs to provide assistance;
Advanced Concept: Caddy in the function of integration into the devops; Related concepts, the service itself has a continuous integration module.
Run Anywhere: This is primarily about the features of the Go application. Go modules are compiled into static libraries, and go applications are statically linked when compiled into executables, with minimal reliance on dynamic libraries, which makes deployment easy to use.

Installation deployment First install the Go Run Environment Go official project Address:

https://golang.org/dl/

Download

wget https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz

Extract

Tar-c/usr/local-xzf go1.8.1.linux-amd64.tar.gz

Create a Go home directory

mkdir/root/go1.8

Setting environment variables
Echo ' Export goroot= $HOME/go1.8 ' >>/etc/profileecho ' export path= $PATH:/usr/local/go/bin ' >>/etc/ Profilesource/etc/profile
Verify the Go version

Go Versiongo version go1.8.1 linux/amd64

Install caddy new user, program directory Modify permissions

Useradd-m Caddy
Chsh-s/bin/false Caddy

Mkdir-p/var/log/caddy/#日志目录

Mkdir-p/etc/caddy/config #配置目录

Chown-r Caddy/etc/caddy
Chown-r Caddy/var/log/caddy

Security considerations: Root operation is not recommended: You can use setcap like this to listen for ports with a port number less than 1024:

sudo setcap cap_net_bind_service=+ep./caddy

Run the command directly as follows (default installation):

Curl Https://getcaddy.com | Bash

View version:

[Email protected] ~]# Caddy-versioncaddy 0.10.0

To view the default plugins:

Caddy command line interface. Run caddy-h to view basic Help information

[Email protected] ~]# Caddy-plugins

Server types:httpcaddyfile loaders:short flag defaultother plugins:http.basicauth http.bind http.browse http.er Rors http.expvar http.ext http.fastcgi http.gzip http.header http.index http.internal http.log http.markdown htt P.maxrequestbody http.mime http.pprof http.proxy http.push http.redir http.rewrite http.root http.status Http.tem Plates http.timeouts Http.websocket shutdown startup TLS tls.storage.file
Install Hook.service,http.git plug-in, the method is as follows;

Curl Https://getcaddy.com | Bash-s Hook.service,http.git

Configure boot-up

Vim/etc/systemd/system/caddy.service

[Unit] Description=caddy Web Server documentation=https://caddyserver.com/docs after=network.target [Service] User=ca Ddy startlimitinterval=86400 startlimitburst=5 limitnofile=16535 execstart=/usr/local/bin/caddy-agree=true-c Onf=/etc/caddy/caddyfile-pidfile=/var/run/caddy/caddy.pid-log=stderr Pidfile=/var/run/caddy/caddy.pid Restart= on-failure [Install] Wantedby=multi-user.target
Service start-Up related settings

chmod 644/etc/systemd/system/caddy.service
Systemctl Enable Caddy.service
Systemctl Start Caddy.service
Systemctl Status Caddy.service

Reference documents

Https://github.com/caddyserver/examples
Https://github.com/Unknwon/wuwen.org/issues/11
http://www.jianshu.com/p/15fc32760993
http://tonybai.com/2015/06/04/caddy-a-web-server-in-go/


This article from "Kang Jianhua" blog, declined reprint!

Web server Rookie Caddy installation deployment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.