Using Nginx auth_basic directive with NodeBalancer
As soon as I put the servers behind a NodeBalancer, all traffic gets stuck in a loop. The username and password is constantly requested. Is there any easy way to avoid this issue?
I'm sorry to hear that you are having trouble getting the auth_basic directive to work properly behind your NodeBalancer. Configuration setups can be tricky, and I'm happy to help!
I took a look at the documentation that Nginx has regarding basic authentication. In their section combining basic authentication with IP restriction it mentions combining IP restriction with HTTP authentication by setting the directive to all access. In this section, you will want to include the IP address of your NodeBalancer.
I'd also like to point out an important note, from our NodeBalancer Reference Guide, for reference when configuring any restrictions on your back-end Linodes:
It’s important to note that while their public IP address is persistent, the private IP address will change. When configuring a firewall or other network restriction on back-end Linodes, be sure to allow the entire 192.168.255.0/24 range and not a specific IP address.
I hope this has been helpful, and feel free to ask the Community any questions you may have by using the reply button below.