4
4
4upik2018-05-24 20:44:29
Nginx
4upik, 2018-05-24 20:44:29

How to set fastcgi_read_timeout 1000 for a specific URL in Nginx?

You need to configure fastcgi_read_timeout 1000 for /etrade_http_tunnel/etrade_http_tunnel.php
I tried setting location like this
location /etrade_http_tunnel/
location /etrade_http_tunnel/etrade_http_tunnel.php
location ^~ /etrade_http_tunnel/
In some cases, the general rule for .php works, in others it gives an error 404
Please help.
nginx code

server {
    listen     ************:443;
    server_name site.ru;
    root        /home/4upik/web/site.ru/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/site.ru.log combined;
    access_log  /var/log/nginx/domains/site.ru.bytes bytes;
    error_log   /var/log/nginx/domains/site.ru.error.log error;

    ssl         on;
    ssl_certificate      /home/4upik/conf/web/ssl.site.ru.pem;
    ssl_certificate_key  /home/4upik/conf/web/ssl.site.ru.key;

    location / {
      if (!-e $request_filename ) { rewrite ^(.*)$ /index.php?q=$1; }

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

location /etrade_http_tunnel/ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_pass 127.0.0.1:9001;
fastcgi_read_timeout 100000;
}

location ~* ^.*(naltovar).* {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_pass 127.0.0.1:9001;
fastcgi_read_timeout 100000;
}

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    127.0.0.1:9001;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }
  error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   /home/4upik/web/site.ru/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   /home/4upik/web/site.ru/stats/;
        include /home/4upik/conf/web/site.ru.auth*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/4upik/conf/web/snginx.site.ru.conf*;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2018-05-26
@dodo512

The doc describes in detail the order of checking location nginx.org/ru/docs/http/ngx_http_core_module.html#l...

To find a location that matches the query, the locations given by prefix strings (prefix locations) are first checked. Among them, a location with a matching prefix of the maximum length is searched and remembered. The regular expressions are then checked, in the order in which they appear in the configuration file. Regular expression checking stops after the first match, and the appropriate configuration is used. If no match is found for the regular expression, then the configuration of the previously stored prefix location is used.
If the matched prefix location of the maximum length has the “^~” modifier, then the regular expressions are not checked.
In addition, using the “=” modifier, you can specify an exact match between URI and location. If there is an exact match, the search stops immediately.

Thus, the request /etrade_http_tunnel/etrade_http_tunnel.php will get into location ~ [^/]\.php(/|$)
even if there are prefixes:
location /etrade_http_tunnel/
location /etrade_http_tunnel/etrade_http_tunnel.php
You need to apply =or ^~to stop the search immediately and regular expressions are not checked.
location = /etrade_http_tunnel/etrade_http_tunnel.php {
    fastcgi_read_timeout 1000;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question