如何将 Nginx 防火墙状态更改为“活动”

Cae*_*sar 6 command-line nginx 16.04

当我查询 netfilter 防火墙状态时,我得到 \xe2\x80\x9cinactive\xe2\x80\x9d:

\n\n
$ sudo ufw status\nStatus: inactive\n
Run Code Online (Sandbox Code Playgroud)\n\n

我想改变它,这样我就可以看到这个:

\n\n
Output\nStatus: active\n\nTo                         Action      From\n--                         ------      ----\nOpenSSH                    ALLOW       Anywhere                  \nNginx HTTP                 ALLOW       Anywhere                  \nOpenSSH (v6)               ALLOW       Anywhere (v6)             \nNginx HTTP (v6)            ALLOW       Anywhere (v6)\n
Run Code Online (Sandbox Code Playgroud)\n\n

我一直在寻找,但没有找到任何有关如何设置状态的信息。

\n

des*_*ert 8

你需要跑

sudo ufw enable
Run Code Online (Sandbox Code Playgroud)

启用防火墙。

您可以ufwhelp.ubuntu.com和上获得更多帮助man ufw

例子

$ sudo ufw enable
Firewall is active and enabled on system startup
$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere                  
22/tcp (v6)                ALLOW       Anywhere (v6)             

$ sudo ufw disable
Firewall stopped and disabled on system startup
$ sudo ufw status
Status: inactive
Run Code Online (Sandbox Code Playgroud)