server {
    listen 8080;
    server_name _;

    client_max_body_size 64m;
    index index.php;

    location = / {
        return 302 /app/androidcast_project/build/;
    }

    location /app/androidcast_project/build/ {
        alias /workspace/examples/build_console/backend/public/;
        index index.php;
        try_files $uri $uri/ @build_front;
    }

    location /app/androidcast_project/crashes/assets/ {
        alias /workspace/examples/crash_reporter/backend/public/assets/;
    }

    location @build_front {
        rewrite ^ /app/androidcast_project/build/index.php?$query_string last;
    }

    location ~ ^/app/androidcast_project/build/(.+\.php)$ {
        alias /workspace/examples/build_console/backend/public/$1;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /workspace/examples/build_console/backend/public/$1;
        fastcgi_param SCRIPT_NAME /app/androidcast_project/build/$1;
        fastcgi_param DOCUMENT_ROOT /workspace/examples/build_console/backend/public;
        fastcgi_pass build-php:9000;
        fastcgi_read_timeout 300s;
    }

    location ~ /\. {
        deny all;
    }
}
