Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Last active April 8, 2016 07:43
Show Gist options
  • Save wokamoto/08a58534592fead516f7 to your computer and use it in GitHub Desktop.
Save wokamoto/08a58534592fead516f7 to your computer and use it in GitHub Desktop.
[AWS][WordPress] WordPress 用 CloudFront 設定サンプル
{
"DistributionConfig": {
"Comment": "",
"CacheBehaviors": {
"Items": [
{
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
"TargetOriginId": "%origin-id%",
"ViewerProtocolPolicy": "allow-all",
"ForwardedValues": {
"Headers": {
"Items": [
"CloudFront-Forwarded-Proto",
"CloudFront-Is-Desktop-Viewer",
"CloudFront-Is-Mobile-Viewer",
"CloudFront-Is-Tablet-Viewer",
"Host",
"User-Agent"
],
"Quantity": 6
},
"Cookies": {
"Forward": "all"
},
"QueryString": true
},
"PathPattern": "*.php",
"SmoothStreaming": false,
"AllowedMethods": {
"Items": [
"HEAD",
"DELETE",
"POST",
"GET",
"OPTIONS",
"PUT",
"PATCH"
],
"CachedMethods": {
"Items": [
"HEAD",
"GET"
],
"Quantity": 2
},
"Quantity": 7
},
"MinTTL": 0
},
{
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
"TargetOriginId": "%origin-id%",
"ViewerProtocolPolicy": "allow-all",
"ForwardedValues": {
"Headers": {
"Items": [
"Accept",
"Authorization",
"CloudFront-Forwarded-Proto",
"CloudFront-Is-Desktop-Viewer",
"CloudFront-Is-Mobile-Viewer",
"CloudFront-Is-Tablet-Viewer",
"Host",
"User-Agent"
],
"Quantity": 8
},
"Cookies": {
"Forward": "all"
},
"QueryString": true
},
"PathPattern": "/wp-admin/*",
"SmoothStreaming": false,
"AllowedMethods": {
"Items": [
"HEAD",
"DELETE",
"POST",
"GET",
"OPTIONS",
"PUT",
"PATCH"
],
"CachedMethods": {
"Items": [
"HEAD",
"GET"
],
"Quantity": 2
},
"Quantity": 7
},
"MinTTL": 0
},
{
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
"TargetOriginId": "%origin-id%",
"ViewerProtocolPolicy": "allow-all",
"ForwardedValues": {
"Headers": {
"Items": [
"Host"
],
"Quantity": 1
},
"Cookies": {
"Forward": "none"
},
"QueryString": true
},
"PathPattern": "/wp-content/uploads/*",
"SmoothStreaming": false,
"AllowedMethods": {
"Items": [
"HEAD",
"GET"
],
"CachedMethods": {
"Items": [
"HEAD",
"GET"
],
"Quantity": 2
},
"Quantity": 2
},
"MinTTL": 43200
},
{
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
"TargetOriginId": "%origin-id%",
"ViewerProtocolPolicy": "allow-all",
"ForwardedValues": {
"Headers": {
"Items": [
"Host"
],
"Quantity": 1
},
"Cookies": {
"Forward": "none"
},
"QueryString": true
},
"PathPattern": "/wp-includes/*",
"SmoothStreaming": false,
"AllowedMethods": {
"Items": [
"HEAD",
"GET"
],
"CachedMethods": {
"Items": [
"HEAD",
"GET"
],
"Quantity": 2
},
"Quantity": 2
},
"MinTTL": 43200
},
{
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
"TargetOriginId": "%origin-id%",
"ViewerProtocolPolicy": "allow-all",
"ForwardedValues": {
"Headers": {
"Items": [
"Host"
],
"Quantity": 1
},
"Cookies": {
"Forward": "none"
},
"QueryString": true
},
"PathPattern": "/wp-content/*",
"SmoothStreaming": false,
"AllowedMethods": {
"Items": [
"HEAD",
"GET"
],
"CachedMethods": {
"Items": [
"HEAD",
"GET"
],
"Quantity": 2
},
"Quantity": 2
},
"MinTTL": 43200
}
],
"Quantity": 5
},
"Logging": {
"Bucket": "",
"Prefix": "",
"Enabled": false,
"IncludeCookies": false
},
"Origins": {
"Items": [
{
"CustomOriginConfig": {
"OriginProtocolPolicy": "http-only",
"HTTPPort": 80,
"HTTPSPort": 443
},
"Id": "%origin-id%",
"DomainName": "origin.example.com"
}
],
"Quantity": 1
},
"DefaultRootObject": "",
"PriceClass": "PriceClass_200",
"Enabled": true,
"DefaultCacheBehavior": {
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
"TargetOriginId": "%origin-id%",
"ViewerProtocolPolicy": "allow-all",
"ForwardedValues": {
"Headers": {
"Items": [
"CloudFront-Forwarded-Proto",
"CloudFront-Is-Desktop-Viewer",
"CloudFront-Is-Mobile-Viewer",
"CloudFront-Is-Tablet-Viewer",
"Host"
],
"Quantity": 5
},
"Cookies": {
"Forward": "whitelist",
"WhitelistedNames": {
"Items": [
"wordpress_*",
"wordpress_logged_in_*"
],
"Quantity": 2
}
},
"QueryString": true
},
"SmoothStreaming": false,
"AllowedMethods": {
"Items": [
"HEAD",
"DELETE",
"POST",
"GET",
"OPTIONS",
"PUT",
"PATCH"
],
"CachedMethods": {
"Items": [
"HEAD",
"GET"
],
"Quantity": 2
},
"Quantity": 7
},
"MinTTL": 0
},
"CallerReference": "%caller-reference%",
"ViewerCertificate": {
"CloudFrontDefaultCertificate": true,
"MinimumProtocolVersion": "SSLv3"
},
"CustomErrorResponses": {
"Quantity": 0
},
"Restrictions": {
"GeoRestriction": {
"RestrictionType": "none",
"Quantity": 0
}
},
"Aliases": {
"Items": [
"www.example.com",
"example.com"
],
"Quantity": 2
}
}
}
#!/bin/sh
source_dist_setting=$(curl -l -s https://gist.githubusercontent.com/wokamoto/08a58534592fead516f7/raw/2749df2f3785f5ec29913ec4425e4d5efd09d300/cloudfront-input.json \
| sed "s/%origin-id%/${domain}/g" \
| sed "s/%caller-reference%/$(date +%s)/g" \
| sed "s/origin.example.com/${origin_url}/g" \
| sed "s/example.com/${domain}/g")
echo ${source_dist_setting}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment