The nginx configuration of the proxy server is as follows:
The code is as follows: |
Copy code |
Server { Listen 80; Server_name *.*; Location /{ Proxy_pass http: // 192.168.0.100: 8001; Proxy_set_header host $ host; Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for; Proxy_set_header X-Real-IP $ remote_addr; Proxy_redirect default; } }
|
Normal access is normal. Once a php program runs for a long time (about 60 seconds), the error 504 will be reported.
Query the official nginx documentation http://nginx.org/en/docs/http/ngx_http_proxy_module.html.
Proxy request
Proxy_connect_timeout connection timeout: 60 seconds by default
Proxy_read_timeout: the read timeout value is 60 seconds by default.
Proxy_send_timeout: the default sending timeout value is 60 seconds.
The long-running php program will be interrupted after 60 seconds, which is affected by proxy_read_timeout and proxy_send_timeout settings.
To ensure that the proxy server runs a php program for a long time without being automatically interrupted, modify the configuration content as follows:
The code is as follows: |
Copy code |
Server { Listen 80; Server_name *.*; Location /{ Proxy_pass http: // 192.168.0.100: 8001; Proxy_connect_timeout 60 s; Proxy_read_timeout 5400 seconds; Proxy_send_timeout 5400 s; Proxy_set_header host $ host; Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for; Proxy_set_header X-Real-IP $ remote_addr; Proxy_redirect default; } }
|