The domain name after reverse proxy is a dynamic domain name, the dynamic domain name is the peanut shell domain name used, the IP address is the home broadband, the router will change when the router is restarted, the dynamic domain name can be resolved normally, but nginx proxy_pass reverse proxy The IP resolved after the domain name is still old, when nginx starts loading the configuration file, it will resolve the domain name to IP, that is, the domain name is only resolved once.
When the dynamic domain IP address changes, when you visit the nginx site, the following appears:504 Gateway Time-out
Solution 1:
Restarting the nginx service, but not in the long run.
Solution 2:
Set the reverse proxy DNS refresh time.
The syntax for resolver is as follows:
Syntax: resolver address ... [valid=time] [ipv6=on|off];
Default: —
Context: http, server, location resolver_timeout is used to specify the timeout for DNS resolution.
Modify the nginx.conf configuration file and add the following to the http node:
Restart the nginx service.
|