Hi there,
I continue with my server setup... I'm trying to setup nginx as the HTTP front end. I have two servers, one for the Zinc SeasideAdaptor running on 8080 and another server running on 8081 (maybe there is a way to run both on the same server). ZnZincServerAdaptor startOn: 8080. ZnServer startDefaultOn: 8081. ZnServer default delegate: (ZnWebSocketDelegate map: 'ws' to: MyWsHandler new). In the Seaside side I have three "entry points": /app : which is a standard Seaside application /app-api/v1/ :which is a WARestfulHandler (REST API, with Basic HTTP Auth) /assets (File Directory for static files) I plan to put a nginx in front of those services, mainly for performance purpose of static file serving, and to avoid the exposure of my server directy to internet. Supposing the hostname is app01.mydomain.com ? My requirements are 1) I want that http://app01.mydomain.com/app be forwarded to http://localhost:8080/app, the same with app-api 2) Same for websockets, maybe to http://ws01.mydomain.com to http://localhost:8081/ws 3) http://app01.mydomain.com/assets be served statically. I know this is a request which isn't directly related with Pharo nor Seaside, but given the fact it's a common setup I hope somebody will help me with this. Sorry for the crosspost. Regards, Esteban A. Maringolo _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
You can do all those things from one nginx configuration file.
see the proxy and rewrite docs here: http://nginx.org/en/docs/ as a guess you want something like: upstream seaside { server 127.0.0.1:8080; } upstream ws { server 127.0.0.1:8081; } server { server_name app01.mydomain.com; root /var/www/mydomain.com; location @myApp{ proxy_pass http://seaside; } location /app{ try_files $uri @myApp; } } server { server_name ws01.mydomain.com; location / { proxy_pass http://ws; } } Hope this helps. Paul
|
Thanks people. I managed to get something working helped by
http://www.monkeysnatchbanana.com/posts/2010/06/23/reverse-proxying-to-seaside-with-nginx.html But looking at the upstream module it seems like a good feature to handle failover servers. I don't understand the @myApp syntax. What is the @ for? Also, looking at Davorin example I see a lot of "tweaks" for Proxy module, many of which must respond to particular tunings I guess, but there are a few that What is this for? proxy_redirect off; I guess this could be useful to get extra datta at the server side: proxy_set_header host $host; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header x-forwarded-host $host; proxy_set_header x-forwarded-port $server_port; This must have to do to prevent Seaside/Zinc from getting excessively big requests. client_max_body_size 10m; client_body_buffer_size 128k; This I can understand :) proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; But then you se proxy_redirect again! proxy_redirect default; Regards! Esteban A. Maringolo 2013/12/12 Paul DeBruicker <[hidden email]>: > You can do all those things from one nginx configuration file. > > see the proxy and rewrite docs here: > > http://nginx.org/en/docs/ > > > as a guess you want something like: > > upstream seaside { > server 127.0.0.1:8080; > } > upstream ws { > server 127.0.0.1:8081; > } > > server { > server_name app01.mydomain.com; > root /var/www/mydomain.com; > location @myApp{ > proxy_pass http://seaside; > } > location /app{ > try_files $uri @myApp; > } > } > > server { > server_name ws01.mydomain.com; > location / { > proxy_pass http://ws; > } > } > > > Hope this helps. > > > Paul > > > > > Esteban A. Maringolo wrote >> Hi there, >> >> I continue with my server setup... >> >> I'm trying to setup nginx as the HTTP front end. >> >> I have two servers, one for the Zinc SeasideAdaptor running on 8080 >> and another server running on 8081 (maybe there is a way to run both >> on the same server). >> >> ZnZincServerAdaptor startOn: 8080. >> ZnServer startDefaultOn: 8081. >> ZnServer default delegate: (ZnWebSocketDelegate map: 'ws' to: MyWsHandler >> new). >> >> In the Seaside side I have three "entry points": >> /app : which is a standard Seaside application >> /app-api/v1/ :which is a WARestfulHandler (REST API, with Basic HTTP Auth) >> /assets (File Directory for static files) >> >> I plan to put a nginx in front of those services, mainly for >> performance purpose of static file serving, and to avoid the exposure >> of my server directy to internet. >> >> Supposing the hostname is app01.mydomain.com ? >> >> My requirements are >> >> 1) I want that http://app01.mydomain.com/app be forwarded to >> http://localhost:8080/app, the same with app-api >> 2) Same for websockets, maybe to http://ws01.mydomain.com to >> http://localhost:8081/ws >> 3) http://app01.mydomain.com/assets be served statically. >> >> I know this is a request which isn't directly related with Pharo nor >> Seaside, but given the fact it's a common setup I hope somebody will >> help me with this. Sorry for the crosspost. >> >> Regards, >> >> >> >> Esteban A. Maringolo >> _______________________________________________ >> seaside mailing list > >> seaside@.squeakfoundation > >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > > > > > -- > View this message in context: http://forum.world.st/Nginx-Reverse-Proxying-tp4729686p4729694.html > Sent from the Seaside General mailing list archive at Nabble.com. > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
On Thu, Dec 12, 2013 at 8:39 PM, Esteban A. Maringolo <[hidden email]> wrote: Also, looking at Davorin example I see a lot of "tweaks" for Proxy As I said my configuration might be a bit rotten, so I am not sure this is necessary, and maybe even wrong. It deals with rewriting urls in responses from server, this just states that all locations returned by the server will be returned as is, and not rewritten by nginx in any way. Docs:
On the other point, I would be a bit weary of proxying WebSockets, and I would be interested if it worked ok for you, and how. Maybe you would need to pay some attention to it in config, and/or use newer version of nginx to make it work.
davorin I guess this could be useful to get extra datta at the server side: _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
2013/12/12 Davorin Rusevljan <[hidden email]>:
> On the other point, I would be a bit weary of proxying WebSockets, and I > would be interested if it worked ok for you, and how. Maybe you would need > to pay some attention to it in config, and/or use newer version of nginx to > make it work. Well it turned out to work pretty much out of the box according to nginx documentation at http://nginx.org/en/docs/http/websocket.html. I added this (websocket is an upstream configuration). server { server_name ws2.mydomain.com; location / { proxy_pass http://websocket; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } I might play with having the websocket upstream as a subdirectory, ej: mydomain.com/ws proxy_pass'ing everying to the upstream websocket. But that will be once I fix the Authorization thing that's driving me nuts. Regards! Esteban A. Maringolo _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |