AWS Lightsail Container + Nginx Setup - Timeout

0

I have deployed a container service with nginx as public endpoint, the nginx is configured to timeout as per the following attributes, however when a long running web request hits the server it times out in 60 seconds irrespective of overridding the default timeouts. The same setup works as expected without 60 seconds timeout in a local docker container configured with exactly identical configuration.

server {
  listen 80;
  sendfile on;
  default_type application/octet-stream;

  gzip on;
  gzip_http_version 1.1;
  gzip_disable      "MSIE [1-6]\.";
  gzip_min_length   256;
  gzip_vary         on;
  gzip_proxied      expired no-cache no-store private auth;
  gzip_types        text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  gzip_comp_level   9;

  root /usr/share/nginx/html;

  location /health/check {
    access_log off;
    return 200;
  }

  location /xyz {
    proxy_pass https://xyz;
    proxy_buffering off;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;

    proxy_read_timeout 1200s;
    proxy_send_timeout 1200s;
    fastcgi_read_timeout 1200s;
    uwsgi_read_timeout 1200s;
  }

  location / {
    try_files $uri $uri/ /index.html =404;
  }

upstream xyz {
  server xyz.domain.com:443;
  keepalive 1;
  keepalive_time 1100;
  keepalive_timeout 1200;
}

I am trying to understand why the same configuration works on a local container as opposed to the one in Lightsail container service.

  • re "a long running web request", can you please update the post with some examples of such requests? this will help us in offering possible answers, and other people who search the web for similar issues. For example, does this mean your application container performs some sort of slow computation before producing response?

  • The underlying proxy that powers "public endpoints" feature has the "idle connection" timeout of 60 seconds, so this is the short answer as to why you get these timeouts.

  • Thank you Pavel for the response.

    It's the server that the container is performing the request which is performing time consuming computations. Is there any way the idle timeout can be increased on the proxy to make the content available to the container?

  • Neeraj, unfortunately this idle time out is currently not modifiable for public endpoints. Perhaps the server application can be changed with that limitation in mind? E.g. you can have an API that starts an expensive computation and responds immediately with an ID which can be used with a separate API that allows you to check if the computation for the given ID has concluded or still in progress. Another approach for long running HTTP interactions is to use https://en.wikipedia.org/wiki/WebSocket Both of these approaches would work well with the idle timeout as it is now.

Neeraj
asked a year ago88 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions