# HTTP — redirect all traffic to HTTPS
server {
    listen 80;
#    listen [::]:80 ipv6only=on;
    server_name api.arqma.com;
    return 301 https://$host$request_uri;
}

# HTTPS — proxy all requests to the pool app
server {
    # Enable HTTP/2
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name your.pool.host;


    # Set files location
    root /var/www/multicoin;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }

    # Set API proxy

    location ~ ^/apiMerged/(.*) {

        proxy_pass http://127.0.0.1:8217/$1$is_args$args;
        proxy_set_header Host $http_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;
    }

    location ~ ^/apiMerged1/(.*) {

        proxy_pass http://127.0.0.1:8317/$1$is_args$args;
        proxy_set_header Host $http_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;
    }
    location ~ ^/apiMerged2/(.*) {

        proxy_pass http://127.0.0.1:8417/$1$is_args$args;
        proxy_set_header Host $http_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;

    }

    location ~ ^/apiMerged3/(.*) {

        proxy_pass http://127.0.0.1:8517/$1$is_args$args;
        proxy_set_header Host $http_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;
    }

    location ~ ^/apiMerged4/(.*) {

        proxy_pass http://127.0.0.1:8617/$1$is_args$args;
        proxy_set_header Host $http_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;
    }

    location ~ ^/apiMerged5/(.*) {

        proxy_pass http://127.0.0.1:8717/$1$is_args$args;
        proxy_set_header Host $http_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;
    }

    location ~ ^/apiMerged6/(.*) {

        proxy_pass http://127.0.0.1:8817/$1$is_args$args;
        proxy_set_header Host $http_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;
    }

    location ~ ^/apiMerged7/(.*) {

        proxy_pass http://127.0.0.1:8917/$1$is_args$args;
        proxy_set_header Host $http_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;
    }


    ssl_certificate /etc/letsencrypt/live/your.pool.host/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/your.pool.host/privkey.pem; # managed by Certbot
}