A
A
Alexander Tartmin2015-07-11 10:42:20
Nginx
Alexander Tartmin, 2015-07-11 10:42:20

How to leave open port only for localhost?

On the nginx server, a NodeJS application is proxied from port 3000. I want to leave only the 22nd and 80th ports on the server for access from outside, and close the rest so that nginx continues to proxy 3000th.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2015-07-11
@baskerville42

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -j DROP

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question