Disclaimer: I have opened this as an issue although I have found and fixed my issue in order to provide feedback and maybe improve the default nginx settings, or at least improve the documentation.
Problem
So, I had this problem that after some unspecified amount of time, all short URLs were returning 504 timeout, while the long URLs were working fine.
After bringing the nextcloud instance down and back up again they worked again for an amount of time.
I use nginx's proxy_pass method to get the short URLs.
I finally got some time to find the problem.
Turns out that the domains specified in the proxy_pass directive are only resolved during nginx start (or reload) and are cached, meaning that if the upstream IP address changes, nginx tries to proxy to a non existent server.
And since I use DDNS domains for my public facing IP, this happens quite often.
Solution
You can "force" nginx to do a lookup on the domain by using variables, but this also changes the default "rewrite" behavior, which means that we have to also manually rewrite the url.
So I changed the suggested location block from:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1:
Disclaimer: I have opened this as an issue although I have found and fixed my issue in order to provide feedback and maybe improve the default nginx settings, or at least improve the documentation.
Problem
So, I had this problem that after some unspecified amount of time, all short URLs were returning 504 timeout, while the long URLs were working fine. After bringing the nextcloud instance down and back up again they worked again for an amount of time. I use nginx's proxy_pass method to get the short URLs.
I finally got some time to find the problem. Turns out that the domains specified in the
proxy_pass
directive are only resolved during nginx start (or reload) and are cached, meaning that if the upstream IP address changes, nginx tries to proxy to a non existent server. And since I use DDNS domains for my public facing IP, this happens quite often.Solution
You can "force" nginx to do a lookup on the domain by using variables, but this also changes the default "rewrite" behavior, which means that we have to also manually rewrite the url. So I changed the suggested location block from:
to:
The
resolver
directive is the address of the DNS server which will resolve the domain name.