danielgormly / statamic-nginx-docker

Basic Statamic & Nginx Docker Setup
29 stars 9 forks source link

Question about statamic.nginx.conf #9

Closed rizkysyazuli closed 4 years ago

rizkysyazuli commented 4 years ago

The included nginx config is a bit different from what we get from Statamic. Especially these two lines. What do they do exactly?

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;

Without these two lines. The served pages just goes blank. So i was wondering why they're not in Statamic's original sample.nginx.conf.

I've been an Apache guy most of my live. Pls forgive my ignorance.

danielgormly commented 4 years ago

It's been a while since I've looked at this project, and I haven't seen Statamic's original sample.nginx.conf but one key difference is probably that the sample's PHP CGI process (the thing that Nginx speaks to that manages PHP processes) is running on the same server. This repo however runs the php-fpm process in an alternate container. Don't know if that has anything to do with your question.

Anyway here is (probably) the pertinent piece of information that answers your question.

The SCRIPT_FILENAME parameter is required as it is passed to PHP FPM to determine the script name. In the builds of NGINX for a lot of Linux distributions, this parameter has been added in fastcgi_params file, i.e. /etc/nginx/fastcgi_paramsso the users could import all the CGI params via theinclude directive, i.e. include fastcgi_params . But for some distributions, such as CentOS, this parameter does not exist in fastcgi_params file. If this parameter is not set, PHP FPM responses 200 OK with empty content, and there is no error or warning. For more informaton about the CGI params, please refer to nginx beginners guide, $_SERVER in PHP and RFC3875.

Full fastcgi_module reference

rizkysyazuli commented 4 years ago

Not in the mood for diving into nginx docs right now 😄 , but you've made it clear about the difference between a basic Statamic setup and this one. That's good enough for now. Thx!