I am using proxy_pass to a dynamic subdomain: proxy_pass https://$remote_user.mydomain.io Is it possible to have the proxy_pass check if the response of https://$remote_user.mydomain.io is 404, if so, simply do: return 404; I.E. don't proxy, immediately return. Posted at Nginx Forum: http://forum.nginx.org/read.php?2,246112,246112#msg-246112