Iptable สำหรับการเปิด Port 443 เพื่อใช้งาน https เข้าเว็บด้วย SSL

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: Iptable สำหรับการเปิด Port 443 เพื่อใช้งาน https เข้าเว็บด้วย SSL

Re: Iptable สำหรับการเปิด Port 443 เพื่อใช้งาน https เข้าเว็บด้วย SSL

โดย mindphp » 27/04/2019 3:12 pm

ถ้าต้องการล้างการ การกำหนดกฏทั้งหมด

โค้ด: เลือกทั้งหมด

# Clear input chain
sudo iptables -F INPUT
# Flush the whole iptables
sudo iptables -F
*** คำสั่งนี้ ถ้าไม่ต้องการ เคลียร์ค่าจริงๆ ห้ามรันนะ ต้อง config ใหม่กันนะหมดนะจ๊ะ

Iptable สำหรับการเปิด Port 443 เพื่อใช้งาน https เข้าเว็บด้วย SSL

โดย mindphp » 27/04/2019 2:59 pm

แก้ไขไฟล์ กฏของ iptable

โค้ด: เลือกทั้งหมด

nano /etc/sysconfig/iptables
เพิ่ม

โค้ด: เลือกทั้งหมด

-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
....
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
หรือ จะเพิ่มด้วย command

โค้ด: เลือกทั้งหมด

iptables -A INPUT -p tcp --dport 443 -j ACCEPT
*** วิธีใช้ ถ้ามีคำสั่งเก่าผิดอยู่ จะทำให้ใช้งานคำสั่งใหม่ที่เพิ่มเข้าไปในกฏไม่ได้

Save ด้วยคำสั่ง

โค้ด: เลือกทั้งหมด

service iptables save
แล้วทดลองรัน คำสั่งเช็ค

โค้ด: เลือกทั้งหมด

 sudo iptables -L
ผลทีไ่ด้
ควรจะมีประมาณนี้

โค้ด: เลือกทั้งหมด

sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:mysql
ACCEPT     udp  --  anywhere             anywhere            udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:EtherNet/IP-1
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:https
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:EtherNet/IP-1
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:https
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:mysql

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

ข้างบน