Last active
May 2, 2023 11:22
-
-
Save LuisPalacios/3cff94bf807965b448d59523537eb9a6 to your computer and use it in GitHub Desktop.
Script apra abrir temporalmente el puerto 80 y hacer port forwarding a mi Nginx Proxy manager
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 | |
# | |
# Para crear/renovar certificados SSL necesito que Let's Encrypt pueda hablar con | |
# el Web Server temporal que "Nginx Proxy Manager". Abro y redirijo el puerto 80 | |
# a mi máquina virtual donde ejecuto NPM. | |
# | |
# Este script está refereciado en el apunte: | |
# https://www.luispa.com/administración/2023/04/08/networking-avanzado.html | |
# | |
IP=192.168.100.243 | |
HOST="npm.tudominio.com" | |
echo | |
iptables -t nat -C PREROUTING -i ppp0 -p tcp -m multiport --dports 80 -j DNAT --to-destination ${IP} 2>/dev/null | |
if [ $? != 0 ] ; then | |
iptables -t nat -I PREROUTING -i ppp0 -p tcp -m multiport --dports 80 -j DNAT --to-destination ${IP} | |
echo "Abierto el PREROUTING a ${HOST}" | |
else | |
echo "El PREROUTING a ${HOST} ya estaba abierto" | |
fi | |
iptables -C FORWARD -p tcp -m multiport --dports 80 -d ${IP} -j ACCEPT 2>/dev/null | |
if [ $? != 0 ] ; then | |
iptables -I FORWARD -p tcp -m multiport --dports 80 -d ${IP} -j ACCEPT | |
echo "Abierto el FORWARD a ${HOST}" | |
else | |
echo "El FORWARD a ${HOST} ya estaba abierto" | |
fi | |
# Comandos para confirmar si están abiertos | |
#iptables -t nat --list PREROUTING | grep DNAT | |
#iptables --list FORWARD -n -v | head | grep "80" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment