upstream api_backend {
    server 127.0.0.1:8080;
}

server {

    listen 80;
    server_name api.hifast.biz  4d3vsw888xgaen.hifast.biz;
    location /.well-known/acme-challenge/ {
        root /var/www/html;
        allow all;
    }
    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl http2;
    server_name api.hifast.biz;
    client_max_body_size 150M;
    ssl_certificate /etc/nginx/ssl/hifast.biz/_.hifast.biz.pem; # managed by Certbot
    ssl_certificate_key /etc/nginx/ssl/hifast.biz/_.hifast.biz.key; # managed by Certbot

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Frame-Options "DENY";
    
    add_header X-Content-Type-Options nosniff;
    if ($http_user_agent ~* '(9999|91\.78)') {
        return 444;
    }
    location ~ ^/v1/common/client/download/file/(?<download_name>Hi快VPN-(?<os>windows|mac|android)-1.0.0-ic-.*\.(?<ext>exe|dmg|apk))$ {
    alias /var/www/download/Hi快VPN-$os-1.0.0.$ext;
    charset utf-8;
    add_header Content-Disposition 'attachment; filename="$download_name"';
    add_header Content-Type application/octet-stream;
    }

    location /v1/common/client/download/file/ {
        alias /var/www/download/;
    }

    location / {
        proxy_pass http://api_backend;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

}

server {
    listen 443 ssl http2;
    server_name 4d3vsw888xgaen.hifast.biz;
    client_max_body_size 150M;
    ssl_certificate /etc/nginx/ssl/hifast.biz/_.hifast.biz.pem; # managed by Certbot
    ssl_certificate_key /etc/nginx/ssl/hifast.biz/_.hifast.biz.key; # managed by Certbot

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;

    gzip on;
    gzip_vary on;
    gzip_min_length 1024;
    gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json image/svg+xml;
    root /var/www/admin;
    location / {
        try_files $uri $uri/ /index.html;
    }

}