1

Introduction:

Please read this serverfault question on nginx load balancing issue with 301 from backend. Somewhat similar to my problem, but the answer doesn't work. Nginx is redirecting to the "name" of my upstream. The point is, this isn't an OpenShift-specific question.


Configuration:

I setup nginx 1.4.4 correctly (built from source, verified that it works properly [1]) on one DIY unscaled gear with OPENSHIFT_DIY_IP 127.8.143.129. Let's call it A. I setup one Tornado server on said gear, and another Tornado on another unscaled gear. (Suppose a gear = red hat linux box on same LAN behind NAT, simplified) Both are simple hello-world apps based on the openshift-hellotornado repo. Let's call this B. B's DNS address is pam-picaxe.rhcloud.com. A's DNS address is main-picaxe.rhcloud.com.

Whenever I'm browsing to main-picaxe.rhcloud.com, the browser is redirected with a 302 Found with

Location: https://frontends/app.

"frontends" here is the name of the upstream in nginx's config. Weird.

[1]: Proof that nginx works with just gear A: If I comment out line 20 and uncomment line 21 in the configuration file (pastebin link at end of post), everything works well and I get a "Hello world!". but whenever I have a case like line 20 (even if it's the DNS address of gear A instead of gear B).

Tried a solution:

I've spent half a day on this, tired of trying to configure this. I tried the solution given in the aforementioned serverfault post, by replacing my location block with:

location / {
            proxy_pass http://frontends;
            proxy_set_header Host $host;
            proxy_redirect http://frontends http://$host:$server_port/;
            proxy_redirect http://frontends:8080/ http://$host:$server_port/;
}

This results in a redirect loop. Sample log output starting from first request to /:

AAA.BBB.CCC.DDD - - [22/Dec/2013:14:53:53 -0500] "GET / HTTP/1.1" 302 331 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31" "WWW.XXX.YYY.ZZZ"
AAA.BBB.CCC.DDD - - [22/Dec/2013:14:53:55 -0500] "GET /app HTTP/1.1" 302 331 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31" "WWW.XXX.YYY.ZZZ"
AAA.BBB.CCC.DDD - - [22/Dec/2013:14:53:55 -0500] "GET /app HTTP/1.1" 302 331 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31" "WWW.XXX.YYY.ZZZ"
AAA.BBB.CCC.DDD - - [22/Dec/2013:14:53:55 -0500] "GET /app HTTP/1.1" 302 331 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31" "WWW.XXX.YYY.ZZZ"
AAA.BBB.CCC.DDD - - [22/Dec/2013:14:53:56 -0500] "GET /app HTTP/1.1" 302 331 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31" "WWW.XXX.YYY.ZZZ"

Any ideas on how I can have a normal load-balanced life with nginx?

Link to nginx.conf: http://pastebin.com/91CMftSc

Nilesh
  • 111
  • 1
  • 3
  • Where is your `upstream` defined? – Michael Hampton Dec 22 '13 at 21:24
  • @MichaelHampton you mean in the configuration file? Edited the question to make the link more visible; here it is again: http://pastebin.com/91CMftSc – Nilesh Dec 22 '13 at 21:26
  • 1
    What you have in pastebin doesn't match what's in your question. I would start over and make sure you have spelled everything correctly. – Michael Hampton Dec 22 '13 at 21:32
  • @MichaelHampton, oops, my bad, thank you! I made the corrections. It's always 'frontends'. – Nilesh Dec 22 '13 at 21:36
  • Turns out this was an OpenShift problem. Beware of their DNS tricks and firewalls. It was done for our own good though, better isolation. – Nilesh May 20 '14 at 20:12

0 Answers0