# =============================================================================
# PLATFORM MARKETING CONTENT - Nginx Configuration
# =============================================================================

upstream pmc_frontend { server 127.0.0.1:3110; keepalive 32; }
upstream pmc_backend { server 127.0.0.1:3111; keepalive 32; }

server {
    listen 80;
    server_name pmc.isem.dev api.pmc.isem.dev;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name pmc.isem.dev;

    ssl_certificate /etc/letsencrypt/live/isem.dev/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/isem.dev/privkey.pem;

    location / {
        proxy_pass http://pmc_frontend;
        proxy_http_version 1.1;
        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;
    }
}

server {
    listen 443 ssl http2;
    server_name api.pmc.isem.dev;

    ssl_certificate /etc/letsencrypt/live/isem.dev/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/isem.dev/privkey.pem;

    client_max_body_size 100M;

    location / {
        proxy_pass http://pmc_backend;
        proxy_http_version 1.1;
        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;
    }
}
