使用docker启动MQ、Redis等服务后发现,这些映射端口无视本机防火墙,检查各种规则,外部仍能随意访问。
后经本帅提醒并查阅资料,最后通过添加IP127+nginx 配置解决。
https://icharle.com/dockeriptables.html
https://www.cnblogs.com/qjfoidnh/p/11567309.html
启用防火墙 sudo yum install firewalld sudo systemctl start firewalld sudo systemctl enable firewalld sudo firewall-cmd –state 特定IP加入白名单 sudo firewall-cmd --permanent --zone=trusted --add-source=10.24.11.133 限定IP段及端口可以访问 sudo firewall-cmd --permanent --zone=drop --add-rich-rule="rule family="ipv4" source address="10.110.0.0/16" port protocol="tcp" port="80" reject" 切换默认区域从 public 到 drop,以达到无视所有接入连接 sudo firewall-cmd --set-default-zone=drop sudo firewall-cmd --reload 启动容器时指定127.0.0.1 docker run -d --name=myrabbit -p 127.0.0.1:5672:5672 -p 127.0.0.1:15672:15672 rabbitmq:management Nginx配置15672 # 四层端口转发 v1.19后支持 #stream { # server { # listen 5672; # proxy_pass 127.0.0.1:5672; # } #} http { # 七层转发 http监控 server { listen 10.110.90.54:15672; server_name rabbitmq; location / { proxy_pass http://127.0.0.1:15672; } } }