Commit 8c29cadb

mo khan <mo@mokhan.ca>
2013-12-28 22:24:25
fixes #8. redirects http naked domain to https www canonical name.
1 parent fbe19ed
Changed files (1)
config
recipes
config/recipes/templates/nginx_unicorn.erb
@@ -7,30 +7,12 @@ client_max_body_size 4G;
 server {
   listen 80 default deferred;
   server_name <%= domain %>;
-  root <%= current_path %>/public;
-  error_log off;
-  access_log off;
-
-  location ^~ /assets/ {
-    gzip_static on;
-    expires max;
-    add_header Cache-Control public;
-  }
-
-  try_files $uri/index.html $uri @unicorn;
-  location @unicorn {
-    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-    proxy_set_header HOST $http_host;
-    proxy_redirect off;
-    proxy_pass http://unicorn;
-  }
-
-  error_page 500 502 503 504 /500.html;
-  keepalive_timeout 10;
+#  return 301 https://<%= domain %>;
+  rewrite        ^ https://$server_name$request_uri? permanent;
 }
 
 server {
-  listen       443;
+  listen 443;
   server_name  <%= domain %>;
   root         <%= current_path %>/public;
   ssl on;
@@ -40,6 +22,12 @@ server {
   access_log /var/log/nginx/<%= application %>.access.log;
 
   try_files $uri/index.html $uri @unicorn;
+  location ^~ /assets/ {
+    gzip_static on;
+    expires max;
+    add_header Cache-Control public;
+  }
+
   location @unicorn {
     proxy_set_header X_FORWARDED_PROTO https;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -48,5 +36,7 @@ server {
     proxy_redirect off;
     proxy_pass http://unicorn;
   }
-}
 
+  error_page 500 502 503 504 /500.html;
+  keepalive_timeout 10;
+}