Forked from yuezhu/gist:47b15b4b8e944221861ccf7d7f5868f5
Last active
May 5, 2020 08:28
-
-
Save shi-yan/dc93b6fb121b89e65ec849e0db68f51e to your computer and use it in GitHub Desktop.
Generate self-signed certificate for HAProxy
This file contains hidden or 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
# Generate a unique private key (KEY) | |
sudo openssl genrsa -out xxx.local.key 2048 | |
# Generating a Certificate Signing Request (CSR) | |
sudo openssl req -new -key xxx.local.key -out xxx.local.csr | |
# Creating a Self-Signed Certificate (CRT) | |
sudo openssl x509 -req -days 365 -in xxx.local.csr -signkey mydomain.key -out xxx.local.crt | |
# Append KEY and CRT to xxx.local.pem | |
sudo bash -c 'cat xxx.local.key xxx.local.crt >> /etc/ssl/private/xxx.local.pem' | |
# Specify PEM in haproxy config | |
sudo vim /etc/haproxy/haproxy.cfg | |
frontend https-in | |
bind *:443 ssl crt /etc/ssl/private/xxx.local.pem | |
acl host_flair hdr(host) -i xxx.local | |
use_backend flair if host_flair |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment