Forked from yuezhu/gist:47b15b4b8e944221861ccf7d7f5868f5
Last active
October 29, 2020 17:58
-
-
Save pulketo/9088a9f44e34a3f6e0017686dcb5bde0 to your computer and use it in GitHub Desktop.
Generate self-signed certificate for HAProxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# usage: ./genhaproxypem.sh domain.com | |
# Generate a unique private key (KEY) | |
sudo openssl genrsa -out $1.key 2048 | |
# Generating a Certificate Signing Request (CSR) | |
sudo openssl req -new -key $1.key -out $1.csr | |
# Creating a Self-Signed Certificate (CRT) | |
openssl x509 -req -days 365 -in $1.csr -signkey $1.key -out $1.crt | |
# Append KEY and CRT to mydomain.pem | |
cat $1.key $1.crt > $1.pem | |
# Specify PEM in haproxy config | |
echo vim /etc/haproxy/haproxy.cfg | |
echo listen haproxy | |
echo " bind 0.0.0.0:443 ssl crt /etc/ssl/private/mydomain.pem" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment