 # Redirect all HTTP trafic to HTTPS
 
 server {
-    listen 80 default_server;
-    listen [::]:80 default_server;
+    listen 80;
+    listen [::]:80;
+
     server_name *.polymyr.com;
-    return 301 https://$server_name$request_uri;
+
+    location ^~ /.well-known/acme-challenge/ {
+        default_type "text/plain";
+        root /tmp/letsencrypt-auto/;
+    }
+
+    location = /.well-known/acme-challenge/ {
+        return 404;
+    }
+
+    location / {
+        return 301 https://$server_name$request_uri;
+    }
 }
 
 server {

proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=static:10m inactive=60m use_temp_path=off max_size=4g;

server {
    listen 80;
    listen [::]:80;

    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    include snippets/ssl-api.polymyr.com.conf;
    include snippets/ssl-params.conf;

    root /home/hakon/polymyr/polymyr-dev-api/;

    server_name static.polymyr.com www.static.polymyr.com;

    location / {
        root /home/hakon/polymyr/polymyr-dev-api/Public;

        include h5bp/basic.conf;

        tcp_nodelay on;

        proxy_cache static;
        try_files $uri =404;
    }
}