give access to just one page for blocked ips in nginx

user156477 asked:

I have a site in development, I want only my IP to access the website and block all other IPs. I could do that with allow in Nginx and deny all. However I want other visitors to see just one page index.html which says:

Welcome to The site, Stay Tuned

how to make only one page accessible for global users like that in Nginx ?

I tried with error_page like

location / {
deny all;
error_page 403 index.html;

but this creates redirects and I get the website has too many redirects while accessing from other ip.

My answer:

You need to allow access to the error page in a matching location.

location = /error403.html {
    allow all;

location / {
    error_page 403 /error403.html;

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.