NginX Vhost not written properly
The current system 3.0.4.1 does not write the configuration files for NginX vhost properly. It does not place the index file references inside of a location that NginX can recognize. Here is the output of a current site configured though ISPConfig.
server { listen *:80;
server_name minecraftarea.com www.minecraftarea.com;
root /var/www/minecraftarea.com/web;
index index.html index.htm index.php index.cgi index.pl index.xhtml;
error_page 400 /error/400.html;
error_page 401 /error/401.html;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 405 /error/405.html;
error_page 500 /error/500.html;
error_page 502 /error/502.html;
error_page 503 /error/503.html;
error_log /var/log/ispconfig/httpd/minecraftarea.com/error.log;
access_log /var/log/ispconfig/httpd/minecraftarea.com/access.log combined;
## Disable .htaccess and other hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location /stats {
index index.html index.php;
auth_basic "Members Only";
auth_basic_user_file /var/www/clients/client1/web3/.htpasswd_stats;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9012;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_intercept_errors on;
}
}
This does not work properly. It is unable to connect to the PHP server, and you get an error of 502. After looking at the configuration file, I realized that there is no location \ defined with the index files inside of it. I fixed the issue by removing the error file references (not sure how to do this properly in NginX), and I added the location \ wrapper around the index files. After these changes, a site that was not loading began loading perfectly.
server { listen *:80;
server_name drewclardy.com www.drewclardy.com;
root /var/www/drewclardy.com/web;
error_log /var/log/ispconfig/httpd/drewclardy.com/error.log;
access_log /var/log/ispconfig/httpd/drewclardy.com/access.log combined;
location / {
index index.html index.htm index.php index.cgi index.pl index.xhtml;
}
## Disable .htaccess and other hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location /stats {
index index.html index.php;
auth_basic "Members Only";
auth_basic_user_file /var/www/clients/client1/web1/.htpasswd_stats;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/web1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_intercept_errors on;
}
}
Another issues that we are going to have is that you can't add more directives to the location \ with the current setup. With this being the case, it is going to be hard for users to add re-write rules for NginX. I think that we need to add some type of parsing so that it can find that location block and add the additional information to it.