0

Inside of my nginx config file, I have several endpoints that use proxy pass to another server which hosts static files. My current settings within the individual site config file is as follow:

    location /some_location {
        proxy_pass http://some.website.url/version/;
        proxy_http_version 1.1;
        proxy_set_header   "Connection" "";
    }

I have the following as proxy parameters

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

What happens is if a request times out for some reason, all future attempts to reach those files results in a 504 Gateway Timeout. Even if the individual files can now be accessed because the issues on the destination server is resolved, I need to restart/reload nginx on the originating server for the requests to work properly.

Is there a way to recycle or reset the connections so that it will be smart and retry the connection after a timeout?

Thanks!

1 Answers1

0

The issue was that the website url's ip address was changing and the way that I was doing it was only resolving the dns on initial startup. Here is what we did to fix it per this post:

    location ~ ^/some_location(/?)(.*)$ {
      resolver "aws_vpc_dns_resolver_ip" valid=10s;
      set $backend "some.website.url";
      proxy_pass http://$backend/version/$2;
      proxy_http_version 1.1;
      proxy_set_header   "Connection" "";
    }