Caddy is a use of the Go language to write HTTP Server, on performance may not be compared to nginx, but in the start and configuration of the difficulty above is really much simpler than nginx. At the same time Caddy support automatically signed let ' s Encrypt SSL certificate, only need to provide a usable mailbox. This article is mainly about how to use caddy to quickly deploy reverse proxies.
All of the following operations are carried out on the debian-7-x86_64 system, if you have trouble using other systems, please leave a message!
First, install the Caddy
The open source community GitHub above has already built the wheel, we use the following command to install directly.
-
Wget-n--no-check-certificate https: //raw.githubusercontent.com/toyodadoubi/doubi/master/caddy_install.sh && chmod +x caddy_install.sh && bash caddy_install.sh install Http.filemanager
The following screen appears to indicate that the Caddy installation was successful and we continue with the following steps.
Ii. configuration file Examples
Here are a few examples of common reverse proxy configuration files, which you can select according to the actual situation.
1. Use IP to reverse HTTP website
The following is the use of IP access, reverse the Caddy configuration of an HTTP protocol site, the site to http://www.baidu.com as an example. You can add them directly using the following Linux commands.
echo ": 80 {
Gzip
Proxy/http://www.baidu.com
} ">/usr/local/caddy/caddyfile
or manually modify the Caddy configuration file to the following, configuration file location:/usr/local/caddy/caddyfile.
: 80 {
Gzip
Proxy/http://www.baidu.com
}
2. Use domain name to reverse HTTP website
The following is a caddy configuration that uses the domain name (in www.banwago.com as an example) to reverse an HTTP protocol site. You can add them directly using the following Linux commands.
echo "Http://www.banwago.com {
Gzip
Proxy/http://www.baidu.com
} ">/usr/local/caddy/caddyfile
or manually modify the Caddy configuration file to the following, configuration file location:/usr/local/caddy/caddyfile.
http://www.banwago.com {
Gzip
Proxy/http://www.baidu.com
}
3. Use domain name to reverse HTTPS website
Using a domain name to reverse HTTPS requires additional configuration of SSL certificates and keys. The following is divided into you have the corresponding SSL file and you do not have the corresponding SSL file to discuss.
(1) If you have the corresponding SSL certificate and key, place the SSL certificate and key (***.CRT and ***.key) of the domain name into the/root directory, and then add it directly using the following Linux command.
echo "Www.banwago.com {
Gzip
Tls/root/***.crt/root/***.key
Proxy/https://www.baidu.com
} ">/usr/local/caddy/caddyfile
or manually modify the Caddy configuration file to the following, configuration file location:/usr/local/caddy/caddyfile.
https://www.banwago.com {
Gzip
Tls/root/***.crt/root/***.key
Proxy/https://www.baidu.com
}
(2) If you do not have the corresponding SSL certificate and key, please set up the domain name resolution first, then replace the ***@***.com in the following command with your mailbox, and then use the following Linux command to add directly.
echo "Https://www.banwago.com {
Gzip
TLS ***@***.com
Proxy/https://www.baidu.com
} ">/usr/local/caddy/caddyfile
If your domain name resolves correctly, then Caddy will automatically help you apply for SSL and renew your contract. The HTTP force jump HTTPS configuration is also added automatically.
Iii. Caddy Use of commands
Start:/etc/init.d/caddy start
Stop:/etc/init.d/caddy stop
Restart:/etc/init.d/caddy restart
View Status:/etc/init.d/caddy status
View Caddy boot log: tail-f/tmp/caddy.log
Caddy configuration file Location:/usr/local/caddy/caddyfile
Caddy automatically request SSL certificate location:/.caddy/acme/acme-v01.api.letsencrypt.org/sites/xxx.xxx (domain name)/
If you want to uninstall caddy, use the following command, enter Y to uninstall after running.
wget-n--no-check-certificate https://raw.githubusercontent.com/pipesocks/install/master/caddy_install.sh && chmod +x caddy_install.sh && bash caddy_install.sh Uninstall
The above is the information of this tutorial, if you encounter any problems, please leave a message to ask questions.
Install Caddy with one click to quickly deploy reverse proxies or mirror sites