E
E
Elder122015-11-20 01:25:29
Nginx
Elder12, 2015-11-20 01:25:29

How to properly configure nginx?

Good day.
The problem is that nginx writes 404 if I go to:
...web/app_dev.php/login.json (this is an api) etc. where there is .*\.json
The configuration file looks like this

server {
    listen       80;
        server_name  server_domain_name_or_IP;

    # note that these lines are originally from the "location /" block
    root   /var/www/html;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /var/www/html;
    }

    location ~ ^(.+?\.php)$ { #возможно дело в этом регулярном выражение, но я разные пробовал варианты, не помогло.
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
        include fastcgi_params;
    }
}

This happens if json comes after the php file, if you go to a separate json file, then it works.
OS Centos7
What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2015-11-20
@gentee

At least there is an error in the regular expression.
I'm not much of a regexp expert, but try this one
Will handle both web/app_dev.php and web/app_dev.php/login.json

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question