 <p>"location" directive should be inside a 'server' directive, e.g.</p> <pre><code>server { listen 8765; location / { resolver 8.8.8.8; proxy_pass http://$http_host$uri$is_args$args; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } </code></pre>