server {
    server_name cherybysanabel.com www.cherybysanabel.com;

    add_header  X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";

    client_max_body_size 100M;

    error_page 503 @custom_503;

	gzip on;
	gzip_types application/font-woff application/font-woff2 text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
	gzip_min_length 1000;
	gzip_vary on;
	gzip_proxied any;
	gzip_comp_level 6;

    location @custom_503 {
        default_type text/plain;
        return 503 "Service Unavailable: The environment is not deployed yet, please try again later.";
    }

    location / {
        set $root_path /home/ubuntu/chery/frontend/master;
        if (!-d $root_path) {
            return 503;
        }

        more_set_headers 'Access-Control-Allow-Origin: $http_origin';
        more_set_headers 'Access-Control-Allow-Methods: GET,POST,PUT,PATCH,DELETE,OPTIONS';
        more_set_headers 'Access-Control-Allow-Credentials:true';
        more_set_headers 'Access-Control-Allow-Headers:Authorization,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

        proxy_pass http://chery-frontend_master;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

	location /_next/static/ {
		alias /home/ubuntu/chery/frontend/master/current/.next/static/;
		expires 1y;
		access_log off;
		add_header Access-Control-Allow-Origin "*";
	}


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/cherybysanabel.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/cherybysanabel.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
    if ($host = www.cherybysanabel.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = cherybysanabel.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    server_name cherybysanabel.com www.cherybysanabel.com;

    listen 80;
    return 404; # managed by Certbot




}
