2023-07-28 22:32:31 +00:00
|
|
|
# haproxy-template
|
|
|
|
|
2024-02-19 19:42:05 +00:00
|
|
|
short template for certbot dns-01 with auto renew (Alpine 3.19 / LXC Proxmox)
|
2024-02-19 18:58:23 +00:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
Add Edge Repos to /etc/apk/repositories
|
2024-02-19 19:42:32 +00:00
|
|
|
```sh
|
2024-02-19 19:00:14 +00:00
|
|
|
cat <<EOF >> /etc/apk/repositories
|
2024-02-19 18:58:23 +00:00
|
|
|
@edge https://dl-cdn.alpinelinux.org/alpine/edge/main
|
|
|
|
@edgecommunity https://dl-cdn.alpinelinux.org/alpine/edge/community
|
|
|
|
@edgetesting https://dl-cdn.alpinelinux.org/alpine/edge/testing
|
2024-02-19 19:00:14 +00:00
|
|
|
EOF
|
2024-02-19 18:58:23 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Update system & install utils
|
2024-02-19 19:42:32 +00:00
|
|
|
```sh
|
2024-02-19 19:56:15 +00:00
|
|
|
apk update && apk upgrade && apk add nano
|
2024-02-19 18:58:23 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Make Folder structure
|
2024-02-19 19:42:32 +00:00
|
|
|
```sh
|
2024-02-19 18:58:23 +00:00
|
|
|
cd && mkdir -p /storage/certs && mkdir -p /storage/cf-tokens && mkdir -p /storage/hooks && chmod 777 -R /storage
|
|
|
|
```
|
|
|
|
|
|
|
|
Install haproxy and cloudflare-dns
|
2024-02-19 19:42:32 +00:00
|
|
|
```sh
|
2024-02-19 18:58:23 +00:00
|
|
|
apk add haproxy certbot@edgecommunity certbot-dns-cloudflare@edgecommunity
|
|
|
|
```
|
|
|
|
|
2024-02-19 19:42:05 +00:00
|
|
|
Add custom scripts and default haproxy config
|
2024-02-19 19:42:32 +00:00
|
|
|
```sh
|
2024-02-19 19:42:05 +00:00
|
|
|
mkdir -p /etc/haproxy && rm /etc/haproxy/haproxy.cfg && mkdir -p /etc/haproxy/ssl
|
|
|
|
wget https://git.hackmi.ch/Phil/haproxy-template/raw/branch/main/haproxy.cfg -O /etc/haproxy/haproxy.cfg
|
|
|
|
wget https://git.hackmi.ch/Phil/haproxy-template/raw/branch/main/genscripts.sh
|
|
|
|
chmod 777 -R /etc/haproxy && chmod 7777 -R genscripts.sh
|
|
|
|
```
|
|
|
|
|
|
|
|
Add haproxy to startup and certbot autorenew to weekly
|
2024-02-19 19:42:32 +00:00
|
|
|
```sh
|
2024-02-19 19:42:05 +00:00
|
|
|
rc-update add haproxy
|
|
|
|
|
|
|
|
cat <<EOF >> /etc/periodic/weekly/certbot-renew
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
certbot renew
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod 777 /etc/periodic/weekly/certbot-renew && chmod +x /etc/periodic/weekly/certbot-renew
|
|
|
|
```
|
|
|
|
|
2024-02-19 20:01:30 +00:00
|
|
|
Add first SSL cert (DNS-Challange) [Cloudflare] [https://developers.cloudflare.com/fundamentals/api/get-started/create-token/] <br>
|
2024-02-19 19:59:44 +00:00
|
|
|
!! IMPORTANT !! -> THIS WILL GENERATE AN SNI WILDCARD (domainwithsslredirect.de, *.domainwithsslredirect.de)
|
2024-02-19 19:42:05 +00:00
|
|
|
```sh
|
|
|
|
./genscripts.sh domainwithsslredirect.de YOUR-API-TOKEN
|
|
|
|
```
|
|
|
|
|
|
|
|
Edit your haproxy config
|
|
|
|
```sh
|
|
|
|
nano /etc/haproxy/haproxy.cfg
|
|
|
|
|
|
|
|
# Change domainwithsslredirect.de with your url
|
|
|
|
# Change service domainxyz to your desire in frontend https and backend
|
|
|
|
# Adjust server web1 10.10.10.10:80 to your destination
|
|
|
|
```
|
|
|
|
|
|
|
|
Restart or reload haproxy
|
|
|
|
```sh
|
|
|
|
service haproxy restart
|
|
|
|
or
|
|
|
|
service haproxy reload
|
|
|
|
```
|
|
|
|
|
|
|
|
Profit
|