Perl nginx REST CGI::Application

491 Views Asked by At

I'm trying to convert a simple CGI::Application::Dispatch based REST application from an Apache server to Nginx. The application runs fine under Apache, but when running under Nginx, only the root layer of Dispatch requests work -- i.e. /app. Any additional parts of the path, for example /app/doit, causes the call to fail with a Forbidden.

I suspect that I need to alter how I am passing the URL to fastcgi, but I'm not clear on how to split it. Most examples I have been able to find are for splitting when there is a dispatcher.cgi type of script, but since C:A:D expects to be called as /app and expects to SEE the /doit part of the URL, I'm not certain how to achieve it.

My current location block is:

    location /app {
    root /var/www;
    gzip off;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/fcgiwrap.socket;
    fastcgi_index index.pl;
    fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
    }

The setup in Apache was very simple:

ScriptAlias /app/ /var/www/app/
    <Directory "/var/www/app">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>
1

There are 1 best solutions below

0
On

possibly adjusting your location, something such as
location ~ ^/app/.*.pl$