S
S
Sergey Pozdnyakov2020-02-21 15:39:38
PHP
Sergey Pozdnyakov, 2020-02-21 15:39:38

How to configure nginx for how much php-fpm?

Good afternoon!
Problem essence: there are 2 servers. Main - nginx+php-fpm+mysql and additional (another physical server, but in 1 local network) - php-fpm
The idea is to redirect part of requests from specific urls to an additional one. Thus unloading the main.

#url который надо обработать на другом сервере
location /cms-new/task-manager {
        try_files $uri index.php?$query_string @php-webhost;
}
location @php-webhost {
#       include nginxconfig.io/php_fastcgi_webhost.conf;
        include fastcgi_params;
        fastcgi_index                   index.php;
        fastcgi_buffers                 8 32k;
        fastcgi_buffer_size             64k;
        fastcgi_param SCRIPT_FILENAME   $realpath_root$fastcgi_script_name;
        fastcgi_pass xxx.xxx.xxx.xxx:9000;
}
#Все остальные обрабатываем на основном
location / {
        try_files $uri /index.php?$query_string;
}

location ~ \.php$ {
        include nginxconfig.io/php_fastcgi.conf;
        fastcgi_read_timeout 600;
}

As a result, in the php-fpm of the additional server, I get "GET /cms-new/task-manager/group/list/index.php" 404
And how can I not configure the processing of this address. How to pass /cms-new/task-manager/group/list/ to index.php processing already? Another problem is that it is not known where this index.php is being looked up.

The upstream format does not suit me, because I need a specific url

UPD Partially figured it out. Got this config
location /cms-new/task-manager {
        try_files $uri /index.php?$query_string @php-webhost;
    }

    location @php-webhost {
        rewrite ^/(.*)$ /index.php?$1 break;
#       root /home/user/project/public;
        include fastcgi_params;
        fastcgi_index                   index.php;
        fastcgi_buffers                 8 32k;
        fastcgi_buffer_size             64k;
        fastcgi_param SCRIPT_FILENAME   /home/user/project/public$fastcgi_script_name;
#$realpath_root
        fastcgi_pass xxx.xxx.xxx.xxx:9000;
    }

$realpath_root points to the same folder as root in the server root. If you uncomment root in the location @php-webhost section, then the pages become 404. It only works fastcgi_param SCRIPT_FILENAME /home/user/project/public$fastcgi_script_name;
On the 2nd server, a different user and the path to the project is different.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2020-02-21
@Jewish_Cat

Here is an article to help you.
If you do not understand, I can describe to you in more detail what needs to be done.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question