worker_processes auto;
#pid /run/nginx.pid;
events { worker_connections 1024; }

http {

    server {
        server_name auth.fumky.org;

        location / {
            proxy_pass http://localhost:3000;
            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;
        }

        listen 3000 ssl;
        ssl_certificate /etc/letsencrypt/live/auth.fumky.org/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/auth.fumky.org/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 {
        server_name auth.fumky.org;

        location / {
            proxy_pass http://localhost:3001;
            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;
        }

        listen 3001 ssl;
        ssl_certificate /etc/letsencrypt/live/auth.fumky.org/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/auth.fumky.org/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 = auth.fumky.org) {
            return 301 https://$http_host$request_uri;
        }

        listen 80;
        server_name auth.fumky.org;
            return 404;
    }
}


