Nginx reverse proxy issue long request

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Nginx reverse proxy issue long request

zakirenish
I'm stuck on a problem for a long time now with two nginxs server which the
first is acting as a reverse proxy and the second as the backend server.

Here is my design :

Client made a GET request on HTTP address from internet
Reverse Proxy Handle it and reverse it to Backend server
Backend server handle it and made a SQL request to an database server
SQL request run while 15min (900MB of Data returned)
PHP-FPM on Backend server will compress the datas and send it back to
reverse proxy
Reverse proxy get back the data and give them back to the client
This design is working well for small SQL request, but as the datas made too
much time to came back to reverse proxy, the connection between reverse
proxy and cliend beeing closed ( I guess ) and the reverse is obliged to
initiate a new one itself

When I made the request from a local client to the local HTTP address of my
reverse proxy it works well

Here is my nginx config

Reverse Proxy :

server {
        listen 80 deferred;

        server_name FQDN;

if ($request_method !~ ^(GET|HEAD|POST|PUT)$ )
        {
                return 405;
        }

        access_log /var/log/nginx/qa.access.log;
        error_log /var/log/nginx/qa.error.log debug;


        location /ws/ {
                proxy_pass      http://IP:8080/;
                proxy_redirect  default;
                proxy_http_version 1.1;
                proxy_set_header Host $host;
                #proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;

                proxy_connect_timeout 1200s;
                proxy_send_timeout 1200s;
                proxy_read_timeout 1200s;
                send_timeout 1200s;
                #proxy_connect_timeout 300s;
                #proxy_send_timeout 300s;

                add_header Front-End_Https on;

        }

        location / {
                return  444;
        }

}

BACKEND server:

server {
        listen 8080 deferred;

       

        root /home/Websites/ws2.5/web;
       
        index index.html index.htm index.nginx-debian.html index.php;

        server_name NAME_BACKEND;
        location / {

                try_files $uri /index.php$is_args$args;
        }


        location ~ ^/index\.php(/|$) {
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                #fastcgi_read_timeout 300;

                fastcgi_send_timeout 1200s;
                fastcgi_read_timeout 1200s;

                fastcgi_split_path_info ^(.+\.php)(/.*)$;
                include fastcgi_params;

               fastcgi_param SCRIPT_FILENAME
$realpath_root$fastcgi_script_name;
                fastcgi_param DOCUMENT_ROOT $realpath_root;
        }
        location ~ \.php$ {
                return 404;
        }

        error_log /var/log/nginx/ws2.5_error.log debug;
        access_log /var/log/nginx/ws2.5_access.log;

        location ~ /\.ht {
                deny all;
        }

}

When it works, here is what I can see in log :

BACKEND - [10/Aug/2020:17:40:22 +0200] "GET /me/patents/ HTTP/1.1" 200
25441300 "-" "RestSharp/105.2.3.0" REVERSE PROXY - [10/Aug/2020:17:41:05
+0200] "GET /ws/me/patents/ HTTP/1.1" 200 25441067 "-"
"RestSharp/105.2.3.0"

And here is what it returned when it doesn't work :

BACKEND - [10/Aug/2020:16:28:39 +0200] "GET /me/patents/ HTTP/1.1" 200
25444257 "-" "RestSharp/105.2.3.0" REVERSE PROXY - [10/Aug/2020:16:29:39
+0200] "GET /ws/me/patents/ HTTP/1.1" 200 142307 "-" "RestSharp/105.2.3.0"

In both case backend send the among of datas expected, but in the second we
can see that the reverse proxy receive less than it sent by BACKEND

I'm totally lost with this

Could you help me ?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,289055,289055#msg-289055

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx