server {
    listen 80;
    server_name localhost.wordpress-docker.com;

    root /var/www/html/wordpress-integration;
    index index.php index.html index.htm;


    # Get real client IP from Kubernetes / Load Balancer
    real_ip_header X-Forwarded-For;
    set_real_ip_from 10.42.0.0/16;
    real_ip_recursive on;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass wordpress:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        # Pass Authorization header
        fastcgi_param HTTP_AUTHORIZATION $http_authorization;
    
        # Extra FastCGI params
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;

        fastcgi_intercept_errors on;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
        try_files $uri =404;
        access_log off;
        expires max;
    }

    location ~ /\.ht {
        deny all;
    }
}
