Simple Rough Caddy Server Use introduction _ Servers Other

Source: Internet
Author: User

Caddy is a go write Server software, the official propaganda language "The HTTP/2 Web server with automatic HTTPS" and "Serve the web like It ' s 2016" concise expression of the software's advantages and trends, it has a basic Apache or Nginx Web server modules, and there are some very distinctive features, such as:

Http/2
Automatic HTTPS
multi-core
WebSockets
Markdown
IPv6
Git
......
With Caddy we can easily deploy a markdown text as a static Web access, or it's git instructions to complete the automated deployment of code, of course, it is very big feature is that its syntax is very concise, more simple than nginx, configuration deployment is very convenient, the following casually cite a few examples.

Add BasicAuth to the site, user name Ryan, password 12345

basicauth / ryan 12345

Solving cross-domain problems with cors

Cors/{
Origin http://allowedSite.com
Origin http://anotherSite.org https://anotherSite.org
Methods Post,put
Allow_credentials false
Max_age 3600
Allowed_headers X-custom-header,x-foobar
Exposed_headers X-something-special,somethingelse
}

IP filtering

IPFilter/{
Rule block
IP 212.10.15.0-255 213.10.15.0-10 5.23.4.24
Blockpage/local/data/default.html
}

HTTPS Configuration
Tls.. /cert.pem.. /key.pem
It is too simple to configure, specifically there are other simple to cry instructions can see the official user Guide, quickly finished brush.

Since caddy automatically deploys HTTPS, and is through let's Encrypt, then practice, this blog is built with Ghost, nginx agent, now switch to caddy, and support HTTPS, the steps are as follows:

Certificate Request please go to let ' s Encrypt
Caddy installation is simple, direct download https://caddyserver.com/docs/getting-started
Configuration Caddyfile, it seems that the instructions are simple and straightforward

Https://www.yuansir-web.com, http://www.yuansir-web.com, http://yuansir-web.com {
 redir https:// Yuansir-web.com{uri}
 TLS yuansir88@gmail.com
}

https://yuansir-web.com {
 gzip
 errors {
  Log/var/log/caddy/yuansir-web.error.log {
    size age
    keep 5
  }
 }
 log/var/log/caddy/ Yuansir-web.access.log
 TLS yuansir88@gmail.com
 proxy/http://127.0.0.1:2368 {
  Proxy_header X-REAL-IP {remote}
  Proxy_header host {host}
  Proxy_header X-forwarded-proto {scheme}
 }
}

Use Supservisor to manage caddy run

[Program:caddy] command=/usr/bin/caddy-conf= "/var/www/caddyfile" DIRECTORY=/VAR/WWW; Directory to CWD to before exec (Def no cwd) autostart=true; Start at Supervisord start (default:true) autorestart=unexpected; Whether/when to restart (default:unexpected) Startsecs=1; Number of secs prog must stay running (def. 1) startretries=3; Max # of Serial start failures (default 3) exitcodes=0,2; ' Expected ' exit codes for process (default 0,2) Stopsignal=quit; Signal used to kill process (default TERM) stopwaitsecs=10; Max num secs to wait b4 SIGKILL (default) Stopasgroup=false; Send stop signal to the UNIX process group (default false) User=www; Setuid to this UNIX account to run the program Redirect_stderr=true; REDIRECT Proc stderr to stdout (default false) Stdout_logfile=/var/log/caddy.log; StdOut log path, none for none; Default AUTO stderr_logfile=/var/log/caddyerr.log; stderr log path, none for none; Default AUTO

Replace a Web site's static resource Cdn with a CDN that supports HTTPS
OK, so simple, nginx switch to caddy, and support HTTPS, really fastest.

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.