如何使用Puppet在IIS中创建多个站点?需要多个site.pp文件吗?
Puppet 配置IIS多站点实现方案
不需要多个site.pp文件,Puppet的入口清单site.pp本身支持在同一个节点定义多个站点资源,你之前配置不生效,通常是类引用格式错误、IIS管理模块未安装、资源参数冲突这几类原因导致。

操作步骤
- 第一步:先安装官方IIS管理模块,在Puppet服务端执行命令:
puppet module install puppetlabs-iis - 第二步:在
site.pp的对应节点配置块里直接定义多个站点资源即可,参考配置示例:
node default { # 先安装IIS核心角色 include iis # 提前创建两个站点的物理目录 file { 'C:\inetpub\Website1': ensure => directory, } file { 'C:\inetpub\Website2': ensure => directory, } # 创建Website1 iis_site { 'Website1': ensure => 'started', physicalpath => 'C:\inetpub\Website1', applicationpool => 'DefaultAppPool', bindings => [ { 'bindinginformation' => '*:80:website1.com', 'protocol' => 'http', }, ], } # 创建Website2 iis_site { 'Website2': ensure => 'started', physicalpath => 'C:\inetpub\Website2', applicationpool => 'DefaultAppPool', bindings => [ { 'bindinginformation' => '*:80:website2.com', 'protocol' => 'http', }, ], } }
- 第三步:如果是部署在GCP Windows虚拟机,额外需要做两个配置:
- 在GCP VPC防火墙规则中放行对应站点端口(示例用的80端口)的入站流量
- 在Windows虚拟机本地防火墙中添加80端口的入站允许规则
注意事项
- 如果两个站点要用同一个端口,必须配置不同的主机头(就是bindinginformation里的域名部分),不然会启动冲突
- 如果不需要域名访问,可以给两个站点配置不同的端口,比如Website1用8081,Website2用8082,就不需要配置主机头
- 修改完site.pp后可以在节点上执行
puppet agent -t手动触发配置生效,排查报错信息
内容的提问来源于stack exchange,提问作者user8226317
相关产品推荐
相关产品推荐

