events {
    worker_connections 1024;
}

http {
    server {
        listen 80;
        server_name localhost;

        location /person-app/ {
            proxy_pass http://person-app:8080/;
            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;
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization';

        }

        location /task-app/ {
            proxy_pass http://task-app:8000/;
            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;
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization';
        }

        # Прокси для Swagger (Stream-сервис)
        #location /stream-service/swagger/ {
        #    proxy_pass http://stream-service:8000/swagger/;
        #    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;
        #}

        # Прокси для Swagger (Message-сервис)
        #location /message-service/swagger/ {
        #    proxy_pass http://message-service:8080/swagger/;
        #    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;
        #}

        #location /stream-service/doc.json {
        #    proxy_pass http://stream-service:8000/doc.json;
        #}

        #location /message-service/doc.json {
        #    proxy_pass http://message-service:8080/doc.json;
        #}
    }
}