Use hostname for set_real_ip_from in Nginx

Mitar asked:

How to use hostname and not directly IP for set_real_ip_from in Nginx? I have a reverse proxy which can change IP as it is restated (it is a Docker container), but I do not want to trust other IPs from the same range (other Docker containers). I am using skydock to keep DNS entries resolve to correct IP for a container, so is there a way to use that for set_real_ip_from instead of static IP?

My answer:


Only if you want to rewrite your nginx configuration every time you restart that container. Better to just give it a static IP address.


View the full question and answer on Server Fault.

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