2

我们转向使用 Puppet 进行管理。使用 apache 模块(来自 Puppet)。

试图找出使 puppet 产生如下内容的语法:

<Directory "/data/websites/mysite">
   ExpiresActive On
   ExpiresDefault "access plus 0 seconds"
   ExpiresByType text/javascript "access plus 12 hours"
   ExpiresByType application/x-javascript "access plus 12 hours"
   ExpiresByType text/css "access plus 12 hours"
   ExpiresByType image/gif "access plus 12 hours"
   ExpiresByType image/jpeg "access plus 12 hours"
   ExpiresByType application/x-shockwave-flash "access plus 12 hours"
</Directory>

我试过这个:

  apache::vhost {  'mysite':
    servername      => 'mysite.com',
    vhost_name      => $::ipaddress,
    port            => '80',
    docroot         => $docroot,

    directories => [
      {
        path => '/var/www/mysite,
        provider => 'directory',
        options => ['-Indexes','FollowSymLinks'],
        expires_active  => 'On',
        expires_default => 'access plus 0 seconds',
        expires_by_type => [
          {'text/javascript' => 'access plus 12 hours' },
          {'application/x-javascript' => 'access plus 12 hours' },
          {'text/css' => 'access plus 12 hours' },
          {'image/gif' => 'access plus 12 hours' },
          {'image/jpeg' => 'access plus 12 hours' },
          {'application/x-shockwave-flash' => 'access plus 12 hours' },
        ],
      },
    ],

  }

这将创建这不是我想要的:

  <Directory "/var/www/mysite">
    Options -Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    ExpiresActive On
    ExpiresDefault access plus 0 seconds
    ExpiresByType {"text/javascript"=>"access plus 12 hours"}
    ExpiresByType {"application/x-javascript"=>"access plus 12 hours"}
    ExpiresByType {"text/css"=>"access plus 12 hours"}
    ExpiresByType {"image/gif"=>"access plus 12 hours"}
    ExpiresByType {"image/jpeg"=>"access plus 12 hours"}
    ExpiresByType {"application/x-shockwave-flash"=>"access plus 12 hours"}
  </Directory>

ExpiresDefault 和 ExpiresByType 不起作用。其余的对我来说看起来不错。

4

1 回答 1

1

如果您将代码更改为:

  apache::vhost {  'mysite':
    servername      => 'mysite.com',
    vhost_name      => '1.1.1.1',
    port            => '80',
    docroot         => 'mydocroot',
    directories => [
      {
        path => '/var/www/mysite',
        provider => 'directory',
        options => ['-Indexes','FollowSymLinks'],
        expires_active  => 'On',
        expires_default => '"access plus 0 seconds"',
        expires_by_type => [
          'text/javascript "access plus 12 hours"',
          'application/x-javascript "access plus 12 hours"',
          'text/css "access plus 12 hours"',
          'image/gif "access plus 12 hours"',
          'image/jpeg "access plus 12 hours"',
          'application/x-shockwave-flash "access plus 12 hours"',
        ],
      },
    ],
  }

你得到:

  <Directory "/var/www/mysite">
    Options -Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    ExpiresActive On
    ExpiresDefault "access plus 0 seconds"
    ExpiresByType text/javascript "access plus 12 hours"
    ExpiresByType application/x-javascript "access plus 12 hours"
    ExpiresByType text/css "access plus 12 hours"
    ExpiresByType image/gif "access plus 12 hours"
    ExpiresByType image/jpeg "access plus 12 hours"
    ExpiresByType application/x-shockwave-flash "access plus 12 hours"
  </Directory>

我没有深入挖掘来确定此行为是否已记录在案,是否令人困惑并且应该修复,应该更好地记录,还是出乎意料。

如果它不是文档中的任何内容,那么肯定有人应该提出拉取请求来改进 Apache 模块。

于 2017-06-16T08:33:55.393 回答