Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Last active November 9, 2016 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wokamoto/4f8f8994efca4e283802e544a431a087 to your computer and use it in GitHub Desktop.
Save wokamoto/4f8f8994efca4e283802e544a431a087 to your computer and use it in GitHub Desktop.
[AWS][CloudFront] CloudFront で HTTPS リクエストを受け付けた場合に X-Forwarded-Proto をちゃんとアプリケーションに渡すには? ref: http://qiita.com/wokamoto/items/2a090ec0c82bcedab12a
SetEnvIf CloudFront-Forwarded-Proto "https" HTTPS
RequestHeader set X-Forwarded-Proto "https" env=HTTPS
server {
...
set $proxy_https '';
if ( $http_cloudfront_forwarded_proto = 'https' ) {
set $proxy_https 'on';
}
if ( $http_x_forwarded_proto = 'https' ) {
set $proxy_https 'on';
}
if ( $scheme = 'https' ) {
set $proxy_https 'on';
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass phpfpm;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $script_root$fastcgi_script_name;
fastcgi_param HTTPS $proxy_https if_not_empty;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment