I am trying to develop a RESTful service using Apache 2 and mod_fastcgi as my transport and security layer.
What I am trying to achieve is that a C++-application is called when a request is made. Then I want to use the HTTP method and the URI to decide (inside the application) which of the (internal) resources should be accessed and in which way.
Calling my C++-FastCGI application works (located @ /var/www/html/foo/fastcgi_test). But only with a specific URI - the URI where my binary is located:
If I open http://127.0.0.1/foo/fastcgi_test in a browser my application runs and returns a html test page like I want. Trying e.g. http://127.0.0.1/foo/bar returns a page with a 404. But I would like the same application to be called (fastcgi_test).
My configuration (so far) looks like this:
<IfModule mod_fastcgi.c>
FastCgiIpcDir /var/lib/apache2/fastcgi
<Location /foo>
SetHandler fastcgi-script
</Location>
FastCgiServer /var/www/html/foo/fastcgi_test -flush
</IfModule>
I read the mod_fastcgi manual and dug through the Apache manuals, but I can't find the right hint. It seems I don't seach for the right key word. As I am very new to Apache configuration I maybe/hopefully just miss the right starting point.
How do I configure Apache/mod_fastcgi to send requests to a "branch of URIs" to the same FastCGI process? Can somebody provide a pointer?
The key is to use an alias. I also moved the FastCGI program out of the content area of Apache into a separate directory (/var/www/fastcgi).
My solution looks like this:
<IfModule mod_fastcgi.c>
FastCgiIpcDir /var/lib/apache2/fastcgi
<Directory /var/www/fastcgi>
SetHandler fastcgi-script
</Directory>
<Location "/foo">
Require all granted
</Location>
FastCgiServer /var/www/fastcgi/fastcgi_test -flush
AliasMatch "/foo(.*)" "/var/www/fastcgi/fastcgi_test"
</IfModule>