0

I've tried the following SO answers without success This one, this one and a few others. I've also looked at the docs, however I can't figure out what I'm doing wrong. When I hit /, I get the nginx home page (fine). When I try to hit /alpha I get 404. Curling to 127.0.0.1:5001 gives me what I expect from the host. Can anyone tell me what I've missed?

Config:

  http {
         server {
                listen 80;

                location /prealpha/ {
                        proxy_pass http://127.0.0.1:5000/;
                }
                location /alpha/ {
                        proxy_pass http://127.0.0.1:5001/;
                }
                location /beta/ {
                        proxy_pass http://127.0.0.1:5002/;
                }
                location /gamma/ {
                        proxy_pass http://127.0.0.1:5003/;
                }
        }

Update It seems like the following log from the debug output of nginx indicates that somehow the keepalive isn't working properly and the connection then gets closed. Do I need to use an upstream or something to make the connection stay open?

2019/09/18 12:11:03 [debug] 8688#8688: *2 http upstream request: "/alpha/?"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http upstream process header
2019/09/18 12:11:03 [debug] 8688#8688: *2 malloc: 000055B88E563AE0:4096
2019/09/18 12:11:03 [debug] 8688#8688: *2 recv: eof:0, avail:1
2019/09/18 12:11:03 [debug] 8688#8688: *2 recv: fd:9 484 of 4096
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy status 404 "404 NOT FOUND"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Server: gunicorn/19.7.1"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Date: Wed, 18 Sep 2019 12:11:03 GMT"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Connection: close"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Content-Type: text/html"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Content-Length: 232"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Set-Cookie: oidc_id_token=; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly; Path=/"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Vary: Cookie"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header done
2019/09/18 12:11:03 [debug] 8688#8688: *2 xslt filter header
2019/09/18 12:11:03 [debug] 8688#8688: *2 posix_memalign: 000055B88E538C60:4096 @16
2019/09/18 12:11:03 [debug] 8688#8688: *2 HTTP/1.1 404 NOT FOUND
Server: nginx/1.14.0 (Ubuntu)
Date: Wed, 18 Sep 2019 12:11:03 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: oidc_id_token=; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly; Path=/
Vary: Cookie
Content-Encoding: gzip

MAJOR UPDATE

It turns out that nginx is passing the location selector (not sure what htis is actually called but in the config at the top it's the bit that says "/prealpha/" for example) to the proxy_pass URL. I need it not to do that. It needs to simply pass everything after that point to the proxy. How do I get it to do that?

David Boshton
  • 2,555
  • 5
  • 30
  • 51

1 Answers1

0

Eventually, https://serverfault.com/a/379679/356031 fixed it.

So in short, no error log and the request getting passed through clearly (once I'd enabled debug logging in nginx), and then after I'd enabled debug logging in gunicorn indicated that the wrong url was being passed through.

David Boshton
  • 2,555
  • 5
  • 30
  • 51