Nginx is reverse proxy for my website and sometimes the website has malfunctions that leads to error pages.
I restarted my application like so:
systemctl restart myapplication.service
and it didn't help.
Then I restarted sql service like so
systemctl restart mssql-server
and it didn't help.
Then I restarted Nginx
service like so
systemctl restart nginx
and vualla the website works again.
So I looked at nginx error log and tried to figure out the problem and I saw thousands lines of these warning:
[warn] 31507#31507: *4839 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/2/20/0000000202 while reading upstream
This is the configuration in my default.conf file:
server {
#listen 80;
listen *:443 ssl;
ssl_certificate /etc/ssl/example.pem;
ssl_certificate_key /etc/ssl/example.key;
server_name example.com *.example.com;
location / {
proxy_pass https://localhost:7001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
I read the answer that was given here that suggests to set the proxy_max_temp_file_size
to 0
but that doesn't make sense to me because if the buffer is full it writes to temp file so why should I limit it to 0?
Other option that I am considering is to increase the buffer size from the defaults but I am not if I should. It says:
Syntax: proxy_buffer_size size;
Default: proxy_buffer_size 4k|8k;
Context: http, server, location
Sets the size of the buffer used for reading the first part of the response received from the proxied server. This part usually contains a small response header. By default, the buffer size is equal to one memory page. This is either 4K or 8K, depending on a platform. It can be made smaller, however.
What should I do?