Help with an nginx reverse proxy to Netlify

Easy thing first – you’ll be happier handling the http → https redirect in nginx. Here’s how we do it in our example: nginx/nginx.conf at master · fly-apps/nginx · GitHub

Does your uptime monitor give you any more details on what’s failing?

This is a shot in the dark, but you might try changing your config to this:

  # We want niice.co traffic to hit our static website
  location = / {
    set $backend "https://niice-blog.netlify.app";
    proxy_pass $backend;

    proxy_set_header        Host                    "niice-blog.netlify.app";
    proxy_set_header        Connection              "";
    proxy_set_header        X-Forwarded-Host        $http_host;
  }

This is doing a couple of things:

  1. Forces NGINX to resolve niice-blog.netlify.app like it’s supposed to. When you hardcode an upstream, it resolves the hostname at startup time and then never again.
  2. Sets the host header to what Netlify expects

Try that out and see if it works better?

1 Like