Nginx Reverse proxy 504 error solution

Source: Internet
Author: User
Tags nginx reverse proxy

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;
        }
    }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.