My server is running on Ubuntu 16.04. One of my web app(php app) was running on my nginx server. To install ModSecurity I removed the NGINX completely and then followed the following steps to complie and install ModSecurity for NGINX as a Dynamic module:
https://www.nginx.com/blog/compiling-and-installing-modsecurity-for-open-source-nginx/
The problem is my NGINX is running but my web app isn't. When I try to visit my domain I get the following error: "404 Not Found-- nginx/1.15.7". I tried to create a test html project at /var/www/html and tried to browse that project and found HTML code is OK, but if I try to put some PHP file it's not working. Though I checked and found php-fpm is running. Here I'm giving my server block:
server {
modsecurity on;
modsecurity_rules_file /etc/nginx/modsec/main.conf;
root /var/www/html/mysite/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name www.mysite.com mysite.com;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html/mysite/public;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Here I should mention that the server block is at /etc/nginx/conf.d/mysite.com.conf
and my project is developed on Laravel.