Puppet Apache 过期代码
Puppet Apache Expires Code
我们转向使用 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 无效。其余的我觉得不错。
如果您将代码更改为:
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 模块。
我们转向使用 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 无效。其余的我觉得不错。
如果您将代码更改为:
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 模块。