Question How can I fix nginx gateway timeouts?

Currently reading
Question How can I fix nginx gateway timeouts?

21
3
NAS
DS1019+
Operating system
  1. Windows
Mobile operating system
  1. iOS
Every time I try and do anything substantial on my webserver, I receive a 504 Gateway Time-out error. I've done lots of googling to increase the timeout, but don't have enough Linux knowledge to apply what I'm reading. Can someone help me out? (And explain why nginx is even getting involved when I've installed apache.)
 
I have configured Web Station to use Apache on the virtual hosts - but it is still getting proxied through nginx for some reasons.
 
I have a bit of Perl CGI that provides a web page of the %ENV hash table. Has a basic password protection to avoid being stumbled on. Some of the SERVER_ fields provide this...

SERVER_PORT443
SERVER_PROTOCOLHTTP/1.1
SERVER_SOFTWAREApache/2.4.39 (Unix)

This from a Web Station request. But since ports 80 and 443 would normally be answered by DSM if Web Station is not installed then it seems probable that DSM is still the primary receiver (nginx) and it is proxying (nginx) all non-Application Portal and Reverse Proxy requests over to Web Station.
 
But since ports 80 and 443 would normally be answered by DSM if Web Station is not installed then it seems probable that DSM is still the primary receiver (nginx) and it is proxying (nginx) all non-Application Portal and Reverse Proxy requests over to Web Station.

Thanks for checking, though I'm not sure that makes complete sense, as surely DMS would use ports 5000 and 5001, not 80 and 443?

So, I either need to disable this proxying, or increase the proxy timeout. Any suggestions? The web is full of people complaining about the problem, but very little help for newbies like me in fixing it.
 
Last edited:
But DSM's Application Portal intercepts ports 80 and 443 for customised domains. Unless Web Station takes over this duty from the core-DSM function then DSM will be listening on 80/443 and redirecting to Web Station.

To understand the exact direction of flows will probably require a support ticket with Synology.

EDIT:

SSH on to the NAS and you can see the configuration of ngnix by running sudo nginx -T. Doing this and I see configuration file for Web Station mentioned at /etc/nginx/app.d/.location.webstation.conf.

I'd run this and capture the output so I can use a text editor to search for interesting strings, such a 'timeout'.

The main configuration files are at /etc/nginx
 
Thank you. I ran `sudo nginx -T`, and copied the output to a text editor. The only obviously relevant line was in /etc/nginx/app.d/.location.webstation.conf – proxy_read_timeout 3600s. However, the timeout I'm experiencing at the moment occurs after just 60s, so this can't be the correct line.

So I searched for lines that specify 60 seconds as a timeout. There were two, both in /etc/nginx/nginx.conf
  • client_body_timeout
  • send_timeout
I changed both of these to 600s, restarted nginx – and success! Thank you.

I guess there's a danger they could both be set back to defaults in the future - but hopefully not.
 
Excellent!

Yes, there's a possibility that they get reset either on reboot or an update. I have the same issue with Mail Server overwriting my catchall mail rules that I've added to its config files.

You could set up a schedule task that runs a script to get the config output, check for these two mods and then write an alert file or something so you can see they are missing.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads

makes you wonder what's wrong with nginx, maybe it's not writing the changes to nginx.conf or something.
Replies
38
Views
5,613
I m feeling stupid !!! How the hell I have not seen thisS !!! Excuse meEE !!! All works like a charm now !
Replies
10
Views
13,239

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Back
Top