linux – Nginx fastcgi cache in a block of different location

I'm trying to cache a different location with a different cache key box, but that does not work. The cache only works for the root location "https://serverfault.com/".

If I disable the cache for the location "https://serverfault.com/", it still does not work for another location.

Block Http:

fastcgi_cache_path /webcache/nginx levels=1:2 keys_zone=microcache:100m max_size=1000m inactive=45m use_temp_path=off;
fastcgi_cache_path /webcache/extreme levels=1:2 keys_zone=extreme:100m max_size=10400m inactive=99999m use_temp_path=off;
fastcgi_cache_key "$scheme$request_method$host$request_uri";

Server block:

location ~* "^/(20(0-1)(0-8)/)" {              
   try_files $uri $uri/ /index.php?$args;
    location ~ .php$ {
        try_files $uri = 404;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass unix:/var/opt/remi/php56/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
        fastcgi_cache_key "$scheme$request_method$host$request_uri";
        fastcgi_no_cache $no_cache;
        fastcgi_cache_bypass $no_cache;
        fastcgi_cache extreme;
        fastcgi_cache_min_uses 1;
        fastcgi_cache_methods GET HEAD;
        fastcgi_cache_lock on;
        fastcgi_cache_lock_age 5s;
        fastcgi_cache_lock_timeout 5s;
        fastcgi_cache_valid 200 302 301 8760h;
        fastcgi_cache_valid 500 502 10s;
        fastcgi_cache_valid 403 404 10s;
        fastcgi_cache_use_stale updating error timeout invalid_header http_500;
        fastcgi_cache_background_update on;
        fastcgi_pass_header Set-Cookie;
        fastcgi_pass_header Cookie;

}

location / {
 try_files $uri $uri/ /index.php?$args;
}


     location ~ .php$ {
        try_files $uri = 404;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass unix:/var/opt/remi/php56/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_intercept_errors on;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_no_cache $no_cache;
    fastcgi_cache_bypass $no_cache;
    fastcgi_cache microcache;
    fastcgi_cache_min_uses 1;
    fastcgi_cache_methods GET HEAD;
    fastcgi_cache_lock on;
    fastcgi_cache_lock_age 5s;
    fastcgi_cache_lock_timeout 5s;
    fastcgi_cache_valid 200 302 301 1m;
    fastcgi_cache_valid 500 502 10s;
    fastcgi_cache_valid 403 404 10s;
    fastcgi_cache_use_stale updating error timeout invalid_header http_500;
    fastcgi_cache_background_update on;
    fastcgi_pass_header Set-Cookie;
    fastcgi_pass_header Cookie;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;


        }

fastcgi – Nginx multiple location with php-fpm

Sorry for this question if it was duplicated or already provided a solution before. However, I tried to keep myself stuck for a day.
Currently, I have my nginx reverse proxy that performs a proxy to 3 local php servers and a remote server.
The three locals are already defined by another person, but I now have to add a new remote control with a new location. Here is my config nginx

 server {
listen 443 ssl http2 default_server;

root    /var/www/;
ssl things...

location / {
    root /var/www/html;
    index   index.php index.html index.htm;
    try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page  404              /404.html;
    location = /404.html {
    root   /var/www/html;
}
error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    root   /var/www/html;
}

location /itop/ {
    index   index.php index.html index.htm;
    try_files $uri $uri/ /index.php?q=$uri&$args;
}
location /asset {
    alias /var/www/asset/public;
    try_files $uri @asset;
    location ~ .php {
        fastcgi_pass 127.0.0.1:9005;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        include fastcgi_params;
    }
}
location @asset {
    rewrite /asset/(.*)$ /asset/index.php?/$1 last;
}
location /hrm {
root /var/www/hrm;
rewrite  ^/hrm/(.*)$ /$1 break;
    try_files $uri @hrm;
}

location @hrm {
    fastcgi_pass 127.0.0.1:9005;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/hrm/symfony/web/index.php;
fastcgi_param SCRIPT_NAME /hrm/symfony/web/index.php;
fastcgi_param REQUEST_URI /hrm$uri?$args;
}

location ~ .php$ {
    fastcgi_pass   127.0.0.1:9005;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    include        fastcgi_params;
}


 location ^~ /vcms {
    rewrite ^/vcms/?(.*)$ /vcms/public/$1 last;
       add_header X-debug-message "vcms1" always;
}

location ^~ /vcms/public {
    add_header X-debug-message "vcms2" always;

    try_files $uri $uri/ /vcms/public/index.php?q=$uri&$args;
    index index.php index.html index.htm;

    root /usr/share/nginx/hd-cmv2/public;#i mounted with nfs from this nginx to the remote php server
    location ~* .php(/|$) {
    rewrite /vcms/public/(.*)$ /$1 break;

    try_files $uri =404;

    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_pass my_remote_phpserver:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

My problem is mm trying to proxy the location / vcms on the remote php server, my nginx configuration seems to be using the php remote proxy server because the log from the remote php-fpm reads "12 / Oct / 2019 : 08: 49: 00 +0700 "GET /index.php" 404 ".
I also have a standalone vcms proxy that only proxies for this php-fpm server which also works fine. However, for a particular reason, I want to add it to the nginx multiple location above. Here is my standalone configuration of nginx for vcms.

 location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.php?q=$uri&$args;
            #try_files $uri $uri/ =404;
    }

location ~ .php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_pass 10.10.11.251:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
}

If I put the above configuration applies to the multiple nginx proxy, I would have the error that every time I access / vcms, I would have the error "impossible to read upstream, fastcgi_pass to my 127.0 .0.1: 9005 local ", so my best bet was to have the / vcms / public file that could replace php-fpm with a proxy, but still not working and getting 404.

I do not know if my nginx configuration has a problem or it's missing something at php-fpm / www.config (but the stand-alone proxy for vcms works fine), or if I have a problem with the existing configuration of nginx.
Thank you for reading my question

How to use python fastCGI on dreamhost?

I've been using CGI since about 1996, so it's probably time to switch to FastCGI or some other software. (Ball?)

I use Dreamhost. I've done some research on Google and found this article, but the article claims to be obsolete and, of course, it does not work.

One of the things I really like about CGI is to be able to change the script and see the results instantly. I know that flask lets a Python script run and reuse it, but you have to modify a file to tell flask to reread your Python file. This seems strange – why does not bottle see that the file has been modified? But I guess that makes sense for big programs that literally have hundreds of python inclusions.

Is FastCGI simply no longer a thing?

Changing Nginx FastCGI buffer sizes for download via the browser

This question is a kind of post-mortem for a problem we had with a dv hosted by Media Temple. We had encountered random issues with our web server (nginx running as a reverse proxy on apache) and were experiencing timeout errors 504 in the scale-up application of the ###################################################################################### 39; application. During my attempts to solve this problem, I've looked at different IM agents on the chat to try to find the source. During one of these debugging sessions, an agent suggested trying to increase the buffer size of nginx fastcgi via Plesk's web user interface in order to Add additional directives to nginx config. He added these lines:

location ~ .php $ {
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
}

I do not remember the reasoning behind the increase in these values, which are by default much smaller sizes.

Later, it happened to me trying to type a direct URL to one of our index files at the root of the application, /franchisee.php. Generally, the URL omits the .php part and .htaccess removes it with the help of mod_rewrite. To my surprise, my browser downloaded the file – it did not even render it as far as .htaccess.

After MT did not understand the cause of the download problems, we finally got a resolution in the form of a hint to remove the above block from nginx config. And bingo: no more downloaded PHP files. But I could not say clearly why these particular directives directed nginx to offer downloadable files instead of parsing and processing them on the server side (the answer to my question "Why adding buffer-sized directives?" he says to nginx "The problem was probably at the origin of downloading the files, because the entries basically told the server to treat php files as downloads rather than make the file as a script of Web page."

My question is: what is the relationship between buffer size and how nginx interprets a file? I realize that buffering would involve temporarily storing data on the file system, but why would this suggest a file to download via HTTPS?

php – Change http_host fastcgi param with nginx

Background: I have an application that runs under a given domain. But in some cases, I need to run it in a different domain than expected (I also potentially alter the port).

I'm trying to customize the fastcgi_param HTTP_HOST, but the application still gets the "real".

Here is what I tried as a configuration:

location ~ [^/] .php (/ | $) {
fastcgi_split_path_info ^ (. +? . php) (/.*) $;

fastcgi_pass php: 9000;
fastcgi_index app.php;
fastcgi_param SCRIPT_FILENAME / app / web $ fastcgi_script_name;
fastcgi_intercept_errors on;
include fastcgi_params;
fastcgi_param SERVER_NAME my-app.com;
fastcgi_param HTTP_HOST my-app.com;
}

There are many problems:

  1. The port is not specified in HTTP_HOST, is there a way to set only the host? (maybe a set a variable that will be used for setting the parameter)
  2. It does not work at all, finally "my-app.com" is not transmitted; Why?

Note: this is based on the nginx docker image.

fastcgi – fcgrid timeout in ISP Manager and unable to edit

I'm trying to install Blesta or WHMCS but both are not installed and after putting the details of the database, I get an error of 500 server.

I've checked the HTTP logs and found this error,

[Sun Dec 16 14:38:53.566519 2018] [fcgid:warn] [pid 4477] [client 103.220.443.202:56738]    mod_fcgid: wait time to read the data in 40 seconds, referent: httpx // domains dot com / billing / install / process /
[Sun Dec 16 14:38:53.566564 2018] [core:error] [pid 4477] [client 103.220.443.202:56738]    End of the script output before the headers: index.php, referer: httpx // domains dot com / billing / install / process /

and when i did research on google, i found that it was an error because i used FastCGI Apache + PHP 7.1 and that i I have to use php7.1 because my wordpress requires php7.x or a later version to work.

Please tell me how to edit the maximum waiting time in fastcgi fcgrid

I've tried editing php 7.1 and php 7.2 at a time with maximum delay, but the error persists and I found that I had to change the fastcgi configuration, but modifying it directly from the root will not solve it. no document indicating where to find the file to edit fastcgi fcgrid