Running a C FastCGI script using NGINX
There are two possibilities that I can think of. You can assign a URI to your CGI program and use that to access it. Or you can send any invalid URI to your CGI program.
In the first case, you could use:
root /nginx/html;index index.html index.htm new.html;location / { try_files $uri $uri/ =404;}location /api { fastcgi_pass 127.0.0.1:8000;}
So, any URI beginning with /api
will be sent to the CGI program. Other URIs will be served by nginx
, unless not found, in which case a 404 response will be returned.
In the second case, you could use:
root /nginx/html;index index.html index.htm new.html;location / { try_files $uri $uri/ @api;}location @api { fastcgi_pass 127.0.0.1:8000;}
So any URI that does not exist will be sent to the CGI program.
See this document for the try_files
directive, and this document for the location
directive.