server {
    listen 80;
    server_name portal.monacousa.org;

    location / {
        return 301 https://$host$request_uri;
    }

    location ^~ /.well-known/acme-challenge/ {
        alias /var/www/html/.well-known/acme-challenge/;
        default_type "text/plain";
        allow all;
    }
}

server {
    listen 443 ssl;
    server_name portal.monacousa.org;

    ssl_certificate     /etc/letsencrypt/live/portal.monacousa.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/portal.monacousa.org/privkey.pem;

    access_log /var/log/nginx/portal.monacousa.org.access.log combined;
    error_log /var/log/nginx/portal.monacousa.org.error.log warn;

    location / {
        proxy_pass http://127.0.0.1:6060;
        proxy_http_version 1.1;
        proxy_set_header Connection "close";
        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_connect_timeout 60s;
        proxy_send_timeout 60s;
        proxy_read_timeout 60s;
        proxy_buffer_size 4k;
        proxy_buffers 4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
    }

    location ^~ /.well-known/acme-challenge/ {
        alias /var/www/html/.well-known/acme-challenge/;
        default_type "text/plain";
        allow all;
    }
}
