Tuesday, June 3, 2014

How to set up executing PHP script before Java app on NGINX

Script should return 403 error to say server to proceed with tomcat proxy pass.
    location / {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass   unix:/run/php5-tomcat.sock;
            fastcgi_index  index.php;
            root /var/www/php;
            include     fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME  $document_root/script.php;
            error_page 403 = @tomcat;
            fastcgi_intercept_errors on;
    }

    location @tomcat {
        proxy_pass http://127.0.0.1:8080;
    }