Custom 401 page not prompting for credentials on nginx
This is how I was able to accomplish what you're trying to do:
## Path must be prefixed with a /, i.e. /401.html, NOT 401.htmlerror_page 401 /401.html;location ~ (401.html)$ { alias /usr/share/nginx/html/$1;}