Last active
November 9, 2016 12:10
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SetEnvIf CloudFront-Forwarded-Proto "https" HTTPS | |
RequestHeader set X-Forwarded-Proto "https" env=HTTPS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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