I have an Nginx web server installed on Centos 8, suddenly after I enable execute PHP in HTML in Nginx configuration I can't log in to some scripts installed like FileRun or ProjectSend or a simple PHP form I created, what I got is when I enter the right login info, the web Page reload that is it and not redirect to the main page or next page after login, I tried to back everything as it was and it still not working.
What I did exactly to Enable executing PHP in HTML is
- change this line location ~ .php$ to location ~ .(php|html|htm)$ {
- after that I go to /etc/php-fpm/www.conf and add this line security.limit_extensions =
- restart both Nginx and PHP-FPM and PHP works fine in HTML
This is the last change I did on my Nginx server and the full Nginx Configuration I use
server {
listen 80;
server_name mydomain.com www.mydomain.com;
return 301 https://$host$request_uri;
}
server {
server_name mydomain.com www.mydomain.com;
root /home/mydomain/public_html;
index index.html index.htm index.php;
access_log /var/log/virtualmin/mydomain.com_access_log;
error_log /var/log/virtualmin/mydomain.com_error_log;
client_max_body_size 4096M;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /home/mydomain/public_html;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
location ~ \.(php|html|htm)$ {
try_files $uri =404;
fastcgi_pass unix:/run/php-fpm/www.sock;
}
location /downloads {
autoindex on;
}
location /license {
try_files $uri $uri/ /license/index.php;
}
listen ip:443 default ssl;
ssl_certificate /home/mydomain/ssl.combined;
ssl_certificate_key /home/mydomain/ssl.key;
fastcgi_read_timeout 60;
}
and what I got from the firefox developer tool (Network) is 2 requests with status 302 Found then it redirects to the same index.php and not make me go to the main page after login.
I don't know what happened but I really stuck at this point and can't find a solution, any suggestions?