[Keter] Keter + Nginx

54 views
Skip to first unread message

Anton Cheshkov

unread,
Jun 6, 2013, 8:50:24 AM6/6/13
to yeso...@googlegroups.com
Hello All, 

please help to understand why this does not work

keter listens 8000 port


#nginx:
server {
    listen 3005;
    server_name 127.0.0.1;
    location / {
      proxy_pass http://127.0.0.1:8000;
    }
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

# app.keter
args:
    - production

extra-hosts:



next, i make curl http://127.0.0.1:3005 

Keter says: The hostname you have provided, 127.0.0.1, is not recognized.


why ?

Thanks.
--
Best regards,
Cheshkov Anton

Patrick Brisbin

unread,
Jun 6, 2013, 9:30:31 AM6/6/13
to yeso...@googlegroups.com
On 06/06/13 at 06:50pm, Anton Cheshkov wrote:
> # app.keter
>
> *host: "127.0.0.1:3005"*
>
> Keter says: The hostname you have provided, 127.0.0.1, is not recognized.
>
> why ?

It might be that "127.0.0.1:3005" != "127.0.0.1".

Did you try removing the ":3005" from app.keter?

--
patrick brisbin

Anton Cheshkov

unread,
Jun 6, 2013, 12:42:27 PM6/6/13
to yeso...@googlegroups.com
Hello Patrick, 

it seems like work, thank you very much. 
What is the logic of work ? why we should miss port ?


2013/6/6 Patrick Brisbin <pbri...@gmail.com>

--
patrick brisbin

--
You received this message because you are subscribed to the Google Groups "Yesod Web Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yesodweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Patrick Brisbin

unread,
Jun 6, 2013, 1:32:40 PM6/6/13
to yeso...@googlegroups.com
On 06/06/13 at 10:42pm, Anton Cheshkov wrote:
> What is the logic of work ? why we should miss port ?

In short, that's just it works :).

The way you had it before, the request would flow like this:

1. Nginx listens on port 3005 of 0.0.0.0
2. Keter listens on port 8000 of 0.0.0.0
3. You deploy a bundle specifying a host of "127.0.0.1" in app.keter
4. Keter starts your app, listening on 127.0.0.1 and *some random port*
4a. Note that keter always starts your app on 127.0.0.1, it's got
nothing to do with the "host" setting.
5. You curl "http://127.0.0.1:3005"
6. That request hits Nginx on port 3005
7. Nginx forwards it to 127.0.0.1 on port 8000 with a Host header of
"127.0.0.1"
8. Keter picks things up on port 8000 and tries to find an app that
answers that Host
9. You've only got one app and it answers to "127.0.0.1:3005"
10. This does not match, Keter gives up and errors

Now that you fixed app.keter, steps 8-10 are a bit different:

8. Keter picks things up on port 8000 and tries to find an app that
answers that Host
9. You've only got one app and it answers to "127.0.0.1"
10. Things match, Keter forwards the request to your app on the randomly
chosen port

Make sense?

--
patrick brisbin

Anton Cheshkov

unread,
Jun 6, 2013, 1:43:35 PM6/6/13
to yeso...@googlegroups.com
a little bit better, but

1) why we point out the port in "extra-host" section
2) what will happen if we'd like to start up another application with keter, for example, responding on "curl 127.0.0.1:3006". will it work ?


2013/6/6 Patrick Brisbin <pbri...@gmail.com>
On 06/06/13 at 10:42pm, Anton Cheshkov wrote:

--
patrick brisbin

--
You received this message because you are subscribed to the Google Groups "Yesod Web Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yesodweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Patrick Brisbin

unread,
Jun 6, 2013, 1:57:48 PM6/6/13
to yeso...@googlegroups.com
On 06/06/13 at 11:43pm, Anton Cheshkov wrote:
> 1) why we point out the port in "extra-host" section

I don't know why you're doing that.

> 2) what will happen if we'd like to start up another application with
> keter, for example, responding on "curl 127.0.0.1:3006". will it work ?

I think you're still confused about who's listening to what...

The 3005 in your example is not the port your app is listening on. It's
the port nginx is listening on.

The 8000 in your example is also not the port your app is listening on,
It's the port keter is listening on.

Your app actually listens on a random port chosen by keter itself. You
need not know or care what it is. Multiple apps would each listen on
different ports, all assigned by keter.

Keter knows which app gets which request by the Host header and matching
it to the host setting in app.keter. It then routes the requests to the
appropriate port for that app.

If you had two apps managed by keter, you could not hit both without
getting DNS involved.

Say you ran foo-bar.com and baz-bat.com on the same box. You would have
to setup a DNS rule to have both of those domains go to the same
physical IP (the box running keter).

Then, foo-bar.keter would specify "foo-bar.com" as host and
baz-bat.keter would specify "baz-bat.com" as host.

You would have to curl either "http://foo-bar.com:3005" or
"http://baz-bat.com:3005" both would end up hitting (ngnix then) keter
on your server and keter would know which app gets which request by the
Host header (which is either "foo-bar.com" or "baz-bat.com").

You could also setup this up locally by adding rules to /etc/hosts
directing both domains 127.0.0.1.

--
patrick brisbin

Anton Cheshkov

unread,
Jun 6, 2013, 2:42:02 PM6/6/13
to yeso...@googlegroups.com
Thank you Patrick, 

i will try to find the place in keter sources to understand exactly how request routing depends on "hosts" and "extra-hots". 


2013/6/6 Patrick Brisbin <pbri...@gmail.com>

--
patrick brisbin

--
You received this message because you are subscribed to the Google Groups "Yesod Web Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yesodweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply all
Reply to author
Forward
0 new messages