Allow multiple IP's to access site while in Maintenance Mode

For Workes & Pages, what is the name of the domain?

NA

What is the error number?

NA

What is the error message?

NA

What is the issue or error you’re encountering

NA

What steps have you taken to resolve the issue?

I am trying to figure out if we can setup maintenance mode to allow multiple IP’s to be able to access it. We already have the worker setup. I found this link which is basically identical to how our’s is configured

https://www.resdevops.com/2018/03/20/Cloudflare-workers-maintenance-mode-static-page/

I assume something has to be changed in this part. I just don’t know what

//Return maint page if you’re not calling from a trusted IP
if (request.headers.get(“cf-connecting-ip”) !== “123.123.123.123”)
{

Greetings,

Thank you for asking.

I have tested it few moments ago and the code is working perfectly fine.

I’ve added my local IP from my wired ISP.
Created a worker and deployed to a route over my domain for testing purpose.

When visited from my PC (wired connection), I get normal response from my Web server.
When I visited from my mobile phone (mobile data connection), I got the maintenance page from the Worker.

I’d suggest you to use the code from Github, since it’s modified and can support more than two IPs. Someone also asked this question in the comments field.

const white_list = [
'1.1.1.1',
'123.123.123.123' --> change to yours, add more 'xxx.xxx.xxx.xxx' coma separated if so

];

Code is here (just replace and add your IPs and modify the text and styling to satisfy your needs as well):

Otherway would be to setup the Access and use Zero Trust for such case:

1 Like

Thanks. Yeah this worked.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.