Cowboy Webserver and Nginx

201 views
Skip to first unread message

asksome...@gmail.com

unread,
Apr 16, 2015, 3:03:33 PM4/16/15
to chica...@googlegroups.com
Hello,

I have a CB app using cowboy and websockets and getting ready for production. Maybe this is a obvious question but i couldnt find the solution.
Is it possible to set nginx in front of a CB app working with cowboy webserver? 
I need this because i need to forward my domain to 8001 port. Domain only works with example: mydomain.com:8001
Any sources or before implementation would be great.

Thanks
Mert

Dmitry Polyanovsky

unread,
Apr 16, 2015, 3:06:33 PM4/16/15
to chica...@googlegroups.com
Hi,

first, you can change port to 80; if nothing else runnign there already
and yes, you can use nginx to proxy requests to CB. Never tried it with websockets but working excellent for regular request on few of my projects

Kai Janson

unread,
Apr 17, 2015, 12:12:57 AM4/17/15
to chica...@googlegroups.com
You can use a firewall rule for that, too. 

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/f877f57e-ca3d-4e43-913c-6992e36e50ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jesse Gumm

unread,
Apr 17, 2015, 12:16:45 AM4/17/15
to chica...@googlegroups.com
Yep, to proxy Websockets with nginx, you need to be using at least
version nginx version 1.4, and add the following rules:


proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

As a practical example, I have the following block in my nginx configs
for each of my apps that run websockets:


location / {
proxy_pass http://127.0.0.1:8020;
proxy_set_header Host $host;
# WebSocket support (nginx 1.4)
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
> https://groups.google.com/d/msgid/chicagoboss/4A001F4B-7325-43CB-BC25-815C29F954DF%40gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm
Reply all
Reply to author
Forward
0 new messages