Preliminary study on Caddy

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Caddy
Similar to Apache,nginx, is a high-performance HTTP and reverse proxy server

Code
Https://github.com/mholt/caddy

Use, first upgrade go to more than 1.9 (https://my.oschina.net/u/2601 ..., and then

go get github.com/mholt/caddy/caddygo get github.com/caddyserver/buildscd $GOPATH/src/github.com/mholt/caddy/caddygo run build.go./caddy

Initially try to create the Caddyfile file in the same directory as the caddy, write the configuration, and then run the Caddy

# cat Caddyfile0.0.0.0:2015pushbrowsewebsocket /echo catext    .htmllog    /var/log/access.logproxy  /api 127.0.0.1:7005header /api Access-Control-Allow-Origin *# # ./caddyActivating privacy features... done.http://0.0.0.0:2015

Effect, ran a simple file server

To turn on HTTPS, you need to add a line configuration Tls/root/ca.pem/root/ca-key.pem,

# cat Caddyfile0.0.0.0:2015 {    gzip    tls /etc/ssl/caddy/ca.pem /etc/ssl/caddy/ca-key.pem    #tls xxxx@qq.com {    #    protocols tls1.0 tls1.2    #}    push    browse    websocket /echo cat    ext    .html    log    /var/log/access.log    proxy  /api 127.0.0.1:7005    header /api Access-Control-Allow-Origin *}# ./caddyActivating privacy features... done.https://0.0.0.0:2015

See a lot of posts said caddy can automatically apply for a certificate, but I tried many times did not succeed. The virtual machine outside the wall is not ...

Reverse proxy, simple configuration as follows, to the original Web services directly added HTTPS, very good.

0.0.0.0:2015 {    gzip    tls /root/ca.pem /root/ca-key.pem    proxy / http://localhost:8080 {        header_upstream Host {host}        header_upstream X-Real-IP {remote}        header_upstream X-Forwarded-For {remote}        header_upstream X-Forwarded-Proto {scheme}    }  

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.