Skip to content

Instantly share code, notes, and snippets.

@rharriso
Created May 24, 2019 18:07
Show Gist options
  • Save rharriso/825643d1e899f96268a800f13ffc58ea to your computer and use it in GitHub Desktop.
Save rharriso/825643d1e899f96268a800f13ffc58ea to your computer and use it in GitHub Desktop.
Change from provided https redirect config
diff --git a/.ebextensions/https-redirect-docker-sc.config b/.ebextensions/https-redirect-docker-sc.config
index fa2fbdc..5ea1cae 100644
--- a/.ebextensions/https-redirect-docker-sc.config
+++ b/.ebextensions/https-redirect-docker-sc.config
@@ -33,14 +33,14 @@ files:
default "upgrade";
"" "";
}
-
+
server {
listen 80;
-
+
gzip on;
gzip_comp_level 4;
gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
-
+
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
@@ -48,24 +48,32 @@ files:
set $hour $4;
}
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
-
+
access_log /var/log/nginx/access.log;
-
+
location / {
- set $redirect 0;
- if ($http_x_forwarded_proto != "https") {
- set $redirect 1;
+ if ($http_x_forwarded_proto = "http") {
+ set $redirect "https";
+ }
+ if ($http_x_forwarded_proto = "ws") {
+ set $redirect "wss";
}
+
if ($http_user_agent ~* "ELB-HealthChecker") {
- set $redirect 0;
+ set $redirect "nope";
+ }
+
+ if ($redirect = "https") {
+ return 301 https://$host$request_uri;
}
- if ($redirect = 1) {
- return 301 https://$host$request_uri;
+
+ if ($redirect = "wss") {
+ return 301 wss://$host$request_uri;
}
-
+
proxy_pass http://docker;
proxy_http_version 1.1;
-
+
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment