I am completely new to nginx . I have project based on angular js which have a index.html, and on a certain event i perform a angular http request to x.php file and fetches the response from it. Its running perfect on my local system and a apache based private hosting server. I created a free tier ec2 instance and started a centos based linux instance on which i hosted the code and installed nginx . Here is my nginx config
server {
listen 80;
server_name mydomain.co.in www.mydomain.co.in;
location / {
root /var/www/html/indm;
index index.php index.html index.htm;
try_files $uri/ $uri /index.php?$query_string =404;
}
location ~ \.php$ {
try_files $uri $uri/ /index.php?q=$uri&$args =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
add_header Access-Control-Allow-Origin *;
proxy_set_header Access-Control-Allow-Origin $http_origin;
}
error_page 500 502 503 504 /50x.html;
At first it was giving me 500 gateway error when the http request was performed on that php file. I check in the XHR request.Here is the error in nginx error.log
[error] 17193#0: *2 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 42.111.38.254
I searched a bit and changed appended a "=404" to try uri statement. But now it redirect to a 404 . I want to run that php file. the server Nginx server is running php fpm is also running
Please help