Modifying fastcgi_params in nginx clashes with nginx_apps.vhost.master
After a maintenance operation I noticed that nginx didn't restart:
/etc/init.d/nginx restart
nginx: [emerg] "fastcgi_read_timeout" directive is duplicate in /etc/nginx/sites-enabled/000-apps.vhost:51 nginx: configuration file /etc/nginx/nginx.conf test failed
Despite this error, the only "fastcgi_read_timeout" that seemed to be present in the apps.vhost file was the one that's placed automatically by ISPconfig and that has its origin in /usr/local/ispconfig/server/conf/nginx_apps.vhost.master:
location ~ ^/phpmyadmin/(.+\.php)$ {
(...) include /etc/nginx/fastcgi_params; (...) fastcgi_read_timeout 240; (...) }
It was however clashing with one that had been set in /etc/nginx/fastcgi_params (to be the default value we needed for most sites), preventing nginx from starting or restarting/reloading when it was already running:
grep fastcgi_read_timeout /etc/nginx/fastcgi_params
fastcgi_read_timeout 5m;
The value in the master file can't be changed unless it is edited, but that will break again in future updates unless it's fixed in next versions of ISPConfig.
To override the value for that particular location, independently of what is in the fastcgi_params file, this seems to work and although it might seem a bit of a hack, probably is a good alternative in nginx apps and vhost master files that include /etc/nginx/fastcgi_params for specific locations:
location ~ ^/phpmyadmin/(.+\.php)$ {
(...)
include /etc/nginx/fastcgi_params;
location ~ .* {
# To access phpMyAdmin, the default user (like www-data on Debian/Ubuntu) must be used
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME document_root
fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_read_timeout 240;
}
}
Another alternative is to just include /etc/nginx/fastcgi_params once, at "location /" level, so it can be overriden in other locations without problems, but might clash with custom settings defined for vhosts.
Best regards.