Last active
February 26, 2023 09:41
-
-
Save amini8/79f0063d04dfd71008a34eac846d5435 to your computer and use it in GitHub Desktop.
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 | |
if [[ "$(uname -s)" == "Linux" ]]; then | |
if [ -f /etc/debian_version ]; then | |
OS="Debian" | |
PKG="apt-get" | |
elif [ -f /etc/redhat-release ]; then | |
OS="Red Hat" | |
PKG="yum" | |
elif [ -f /etc/arch-release ]; then | |
OS="Arch" | |
PKG="pacman" | |
else | |
echo "Unsupported operating system" | |
exit 1 | |
fi | |
else | |
echo "Unsupported operating system" | |
exit 1 | |
fi | |
if [[ "$PKG" == "apt-get" ]]; then | |
sudo $PKG update | |
sudo $PKG install -y openssl stunnel4 | |
elif [[ "$PKG" == "yum" ]]; then | |
sudo $PKG update | |
sudo $PKG install -y openssl stunnel | |
elif [[ "$PKG" == "pacman" ]]; then | |
sudo $PKG -Syu | |
sudo $PKG -S openssl stunnel | |
fi | |
sudo openssl genrsa -out key.pem 2048 | |
sudo openssl req -new -key key.pem -out cert.csr -subj "/CN=localhost" | |
sudo openssl x509 -req -in cert.csr -signkey key.pem -out cert.pem | |
sudo tee /etc/stunnel/stunnel.conf > /dev/null <<EOF | |
pid=/var/run/stunnel.pid | |
output=/var/log/stunnel.log | |
[proxy] | |
accept = 443 | |
client = yes | |
connect = 127.0.0.1:8080 | |
cert = /etc/stunnel/cert.pem | |
key = /etc/stunnel/key.pem | |
EOF | |
sudo systemctl start stunnel | |
sudo systemctl enable stunnel | |
echo "SNI proxy installation and configuration is complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment