Skip to content

Instantly share code, notes, and snippets.

@MaherSaif
Last active October 30, 2024 01:21
Show Gist options
  • Save MaherSaif/c02001bc045a036e7b3d4099baa48eb6 to your computer and use it in GitHub Desktop.
Save MaherSaif/c02001bc045a036e7b3d4099baa48eb6 to your computer and use it in GitHub Desktop.
replace ngrok with nginx/ssh.
ln -s /etc/nginx/sites-available/dev /etc/nginx/sites-enabled/
# Install Certbot (letsencrypt)
echo 'deb http://deb.debian.org/debian stretch-backports main' >>
/etc/apt/sources.list
gpg --keyserver pgp.mit.edu --recv-keys 7638D0442B90D010
8B48AD6246925553
gpg --armor --export 7638D0442B90D010 | apt-key add -
gpg --armor --export 8B48AD6246925553 | apt-key add -
apt update
apt install certbot python-certbot-nginx -t stretch-backports
# Then locally I start an ssh tunnel to the server
# Locally on your computer
ssh -N -R 4040:localhost:8000 [email protected]
# On your server in the cloud
# Setup Firewall
ufw allow ssh/tcp
ufw allow http/tcp
ufw allow https/tcp
ufw logging on
ufw enable
ufw status
# Install Nginx
apt update
apt install nginx
# Add a dev forwarding endpoint
cat > /etc/nginx/sites-available/dev <<'CONF'
server {
listen 80;
listen [::]:80;
server_name dev.yourservername.com;
location ~ /.well-known {
root /var/www/html;
allow all;
}
location / {
proxy_pass http://127.0.0.1:4040/;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
CONF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment