Skip to content

Instantly share code, notes, and snippets.

@Alex4386
Last active March 5, 2026 08:57
Show Gist options
  • Select an option

  • Save Alex4386/2f7b198053e53f62845812ad1b76b65d to your computer and use it in GitHub Desktop.

Select an option

Save Alex4386/2f7b198053e53f62845812ad1b76b65d to your computer and use it in GitHub Desktop.
Envoy Setup
#!/bin/bash
# 1. Create the configuration directory
if [ ! -d "/etc/envoy" ]; then
echo "Creating /etc/envoy directory..."
sudo mkdir -p /etc/envoy
sudo chmod 755 /etc/envoy
fi
# 2. Create system user for Envoy (if it doesn't exist)
if ! id "envoy" &>/dev/null; then
echo "Creating system user: envoy..."
sudo useradd -r -s /bin/false envoy
fi
# 3. Create the systemd service file
echo "Creating /etc/systemd/system/envoy.service..."
cat <<EOF | sudo tee /etc/systemd/system/envoy.service
[Unit]
Description=Envoy Proxy
After=network.target
ConditionPathExists=/etc/envoy/envoy.yml
[Service]
User=envoy
Group=envoy
PermissionsStartOnly=true
ExecStartPre=+/usr/bin/envoy --mode validate -c /etc/envoy/envoy.yml
ExecStartPre=+/usr/bin/mkdir -p /run/envoy /run/envoy-proxies
ExecStartPre=+/usr/bin/chown -R envoy:envoy /run/envoy /run/envoy-proxies
ExecStartPre=+/usr/bin/mkdir -p /var/log/envoy
ExecStartPre=+/usr/bin/chown envoy:envoy -R /var/log/envoy
ExecStart=/usr/bin/envoy -c /etc/envoy/envoy.yml
Restart=always
RestartSec=5
KillMode=process
[Install]
WantedBy=multi-user.target
EOF
YOUR_EDITOR="${EDITOR:-vim}"
# 4. Final Instruction for the user
echo "--------------------------------------------------------"
echo "SETUP STEPS REMAINING:"
echo "1. Create your config: sudo $YOUR_EDITOR /etc/envoy/envoy.yml"
echo "2. Set ownership: sudo chown envoy:envoy /etc/envoy/envoy.yml"
echo "3. Reload systemd: sudo systemctl daemon-reload"
echo "4. Setup service: sudo systemctl enable --now envoy"
echo "--------------------------------------------------------"
@Alex4386
Copy link
Author

Alex4386 commented Mar 5, 2026

curl -sSL https://gist.githubusercontent.com/Alex4386/2f7b198053e53f62845812ad1b76b65d/raw/envoy-setup.sh | sudo bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment