前提条件:WAN接口必须是公网IP。

本教程以设置xxx.pfchina.org域名访问为例,介绍设置步骤。

修改默认端口

博主所在的区域,IPFire默认444访问端口被运营商关闭了,需要修改为其他可用端口,本文使用8443端口。在IPFire的Web配置界面,没有修改访问端口的选项,需要手动修改以下文件:

/etc/httpd/conf/vhosts.d/ipfire-interface.conf
 
 /etc/httpd/conf/vhosts.d/ipfire-interface-ssl.conf
 
 /etc/httpd/conf/listen.conf
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

将以上文件里的444端口修改为8443,修改完成以后,重启apache:

/etc/init.d/apache restart
  • 1.

添加防火墙规则

在防火墙上,添加一条规则,放开WAN接口8443端口的访问。

  • 源:标准网络(红色)
  • 目标:firewall RED
  • 协议:tcp,
  • 目标端口:8443
    保存并应用更改。

IPFire远程SSL访问设置教程_SSL

添加完成后下图所示:

IPFire远程SSL访问设置教程_IPFire_02

使用https://wan ip:8443测试,检查是否能正常远程访问IPFire防火墙。

添加域名解析

登录CloudFlare,添加一条DNS解析记录。将xxx.pfchina.org指向IPFire的WAN接口IP。

IPFire远程SSL访问设置教程_IPFire_03

修改主机名、域名

进入IPFire的shell环境下,运行setup命令修改防火墙的主机名和域名,主机名修改为xxx,域名修改为pfchina.org。

安装ACEM

运行以下命令,安装acme.sh。

curl https://get.acme.sh | sh -s email=xxx@xxx.com
  • 1.

导入CF帐号和KEY

由于运营商封掉了443和80端口,ACME挑战类型只能使用DNS-01方式,需要导入CloudFlare的帐号和KEY。

export CF_Email="xxx@xxx.com"
 
 export CF_Key="f586ab52047a8d9594ffb23a3ac642c84af51"
  • 1.
  • 2.
  • 3.

申请证书

运行以下命令,申请证书:

/root/.acme.sh/acme.sh --issue --dns dns_cf -d xxx.pfchina.org -d www.xxx.pfchina.org
  • 1.

申请成功会显示如下内容:

[Sat Jun 29 03:42:22 PM CST 2024] Your cert is in: /root/.acme.sh/xxx.pfchina.org_ecc/xxx.pfchina.org.cer
 
 [Sat Jun 29 03:42:22 PM CST 2024] Your cert key is in: /root/.acme.sh/xxx.pfchina.org_ecc/xxx.pfchina.org.key
 
 [Sat Jun 29 03:42:22 PM CST 2024] The intermediate CA cert is in: /root/.acme.sh/xxx.pfchina.org_ecc/ca.cer
 
 [Sat Jun 29 03:42:22 PM CST 2024] And the full chain certs is there: /root/.acme.sh/xxx.pfchina.org_ecc/fullchain.cer
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

修改IPfire默认证书

修改/etc/httpd/conf/vhosts.d/ipfire-interface-ssl.conf,找到SSLEngine on行,将证书和密钥修改为前面申请的域名证书,并将server-ecdsa密钥和证书删除。如下所示:

SSLEngine on
 
 SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
 
 SSLCipherSuite AESGCM+EECDH:CHACHA20+EECDH:@STRENGTH:+aRSA
 
 SSLHonorCipherOrder on
 
 SSLCompression off
 
 SSLSessionTickets off
 
 SSLCertificateFile /root/.acme.sh/xxx.pfchina.org_ecc/xxx.pfchina.org.cer
 
 SSLCertificateKeyFile /root/.acme.sh/xxx.pfchina.org_ecc/xxx.pfchina.org.key
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.

修改完成以后,重启apache:

/etc/init.d/apache restart
  • 1.

现在用https://xxx.pfchina.org:8443测试,检查是否挂锁成功。

其他修改

1.修改IPFire徽标对应的链接
/srv/web/ipfire/html/themes/ipfire/include/functions.pl
搜索:https://www.ipfire.org 替换即可。

2.去除赞助提示
/srv/web/ipfire/html/themes/ipfire/include/functions.pl
在216、217行,删除有ipfire链接的两行即可。

3.修改菜单内容
/var/ipfire/menu.d目录对应了各级菜单的显示内容。

其他文章:

 IPFire防火墙汉化包