Answer the question
In order to leave comments, you need to log in
How to setup iptables for webserver on ubuntu 14.04?
Good afternoon colleagues, there is a server on ubuntu 14.04, you need to configure iptables for the web server is apache2 + nginx.
I just started to study Iptables and therefore I don’t really understand it, I will be glad for any help!
Answer the question
In order to leave comments, you need to log in
Allow connection via ssh and http\https to the INPUT chain. In the same place, allow a local loop.
Set the default policies for the INPUT and FORWARD chain to DROP.
It should turn out something like this:
#!/bin/bash
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp -m conntrack --ctstate NEW --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -m conntrack --ctstate NEW --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m conntrack --ctstate NEW --dport 443 -j ACCEPT
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question