<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>
<body>
<div name="messageBodySection">
<div dir="auto">On my staging server, I stopped container aaa (with IP address x.x.x.5); I then restarted container bbb (with IP address x.x.x.6); finally, I started aaa again. As expected, when bbb restarted it claimed aaa’s old IP address, since it was the
lowest available address. When aaa started back up, it took bbb’s old IP, so they ended up swapping IP addresses, but nginx thinks they’re at their original locations.<br>
<br>
Once again, thank you for your help with this. As I mentioned, I’m probably just going to make Docker assign fixed addresses to each container so that nginx can look up the names once.<br>
<br>
If you are interested in that sort of thing, please leave an answer at <a href="https://serverfault.com/questions/1117412/nginx-serving-content-from-wrong-proxy" target="_blank">https://serverfault.com/questions/1117412/nginx-serving-content-from-wrong-proxy</a> and
I’ll be happy to mark it correct.<br>
</div>
</div>
<div name="messageReplySection">
<div dir="auto"><span style="font-size: 12pt"><br>
</span></div>
<blockquote style="border-left-color: rgb(26, 188, 156); margin: 5px; padding-left: 10px; border-left-width: thin; border-left-style: solid;">
<span style="color:#000000;background-color:#ffffff;font-family:Calibri, Arial, Helvetica, sans-serif;font-size: 12pt">I'll bet that's it! There is nothing in my configuration that makes the IP addresses of the containers in the Docker network stay fixed. I
would not be surprised if, when two or more containers are restarted (as they probably are every once in a while when logrotate runs), some or all of them may exchange IP addresses.</span><br>
<span style="color:#000000;background-color:#ffffff;font-family:Calibri, Arial, Helvetica, sans-serif;font-size: 12pt">I will try to duplicate this so I can post the results here, but in any case I will find out how to assign specific IP addresses to the containers
in the Docker configuration and do that from now on. Your observation that nginx looks up the IP once and assumes it will not change would explain what is going on.</span><br>
<span style="color:#000000;font-family:Calibri, Arial, Helvetica, sans-serif;font-size: 12pt">I can't thank you enough, as this was driving me crazy.</span><br>
<span style="color:#000000;font-family:Calibri, Arial, Helvetica, sans-serif;font-size: 12pt">Thank you also for your other very helpful suggestions (reloading nginx instead of restarting, forcing DNS lookups).</span><br>
<blockquote style="border-left-color: rgb(230, 126, 34); margin: 5px; padding-left: 10px; border-left-width: thin; border-left-style: solid;">
<span style="color:#666666;font-size: small">Do the ip addresses for the rails sites change over time?</span><span style="color:#666666;font-size: small">Mind that nginx will query the hostname only once (at startup/reload),</span><span style="color:#666666;font-size: small">*and
use that same ip forever*</span><span style="color:#666666;font-size: small">If the other containers switched ips, that would produce the exact</span><span style="color:#666666;font-size: small">behavior that you are seeing.</span><br>
</blockquote>
<br>
<br>
<br>
</blockquote>
</div>
</body>
</html>