Here is the relevant part of my Nginx configuration file:
http {
log_format fastcgi
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$fastcgi_script_name" "$fastcgi_path_info"';
server {
listen 8080;
server_name localhost;
access_log /usr/local/var/log/nginx/access.log fastcgi;
location / {
fastcgi_index /;
fastcgi_pass unix:/usr/local/var/www/run/httpd.sock;
include fastcgi_params;
}
}
}
Basically I have a Unix socket at /usr/local/var/www/run/httpd.sock
which handles FastCGI requests, and it works quite well. The problem here is that Nginx thinks the last part of the URI is the script name, but it should be the path info. For example
⇒ nginx -v
nginx version: nginx/1.15.0
⇒ nginx
⇒ curl -i localhost:8080/index
HTTP/1.1 200 OK
Server: nginx/1.15.0
Date: Tue, 10 Jul 2018 12:27:15 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
<p>hello, world</p>
⇒ tail -n 1 /usr/local/var/log/nginx/access.log
127.0.0.1 - - [10/Jul/2018:20:27:15 +0800] "GET /index HTTP/1.1" 200 30 "-" "/index" ""
This means $fastcgi_script_name
is /index
, with $fastcgi_script_name
being an empty string.
How can I configure Nginx to make $fastcgi_script_name
to contain the last part of a URI, i.e. things like /index
?