restrict firewall commands to host IP and expose service on all interfaces

This commit is contained in:
CPTN Cosmo 2026-04-18 16:43:44 +02:00
parent 000aa5710b
commit 340f8e5bef
2 changed files with 10 additions and 6 deletions

View file

@ -6,11 +6,15 @@ document.addEventListener('DOMContentLoaded', () => {
const ufwCmd = document.getElementById('ufw-cmd');
const iptablesCmd = document.getElementById('iptables-cmd');
portInput.addEventListener('input', (e) => {
const port = e.target.value || '4646';
ufwCmd.textContent = `sudo ufw allow ${port}/tcp`;
iptablesCmd.textContent = `sudo iptables -I INPUT -p tcp --dport ${port} -j ACCEPT`;
});
const updateFirewallCmds = () => {
const port = portInput.value || '4646';
const hostIp = window.location.hostname;
ufwCmd.textContent = `sudo ufw allow from ${hostIp} to any port ${port} proto tcp`;
iptablesCmd.textContent = `sudo iptables -I INPUT -p tcp -s ${hostIp} --dport ${port} -j ACCEPT`;
};
portInput.addEventListener('input', updateFirewallCmds);
updateFirewallCmds();
const fetchInstances = async () => {
try {