wandenberg / nginx-push-stream-module

A pure stream http push technology for your Nginx setup. Comet made easy and really scalable.
Other
2.22k stars 295 forks source link

Multiple message buses in one nginx. #108

Closed AlexeyKupershtokh closed 10 years ago

AlexeyKupershtokh commented 10 years ago

Hello. I would like to use nginx-push-stream-module with a few separate projects and would like them use intersecting channel names. But I want to make the them isolated somehow by identifying a bus they publish/subscribe. A configuration example would look something like defining two hosts in the same nginx:

server {
  server_name project1.myserver.com;
  push_stream_bus_id project1;
  location /pub { ... }
  location ~ /sub-ev/(.*) { ... }
}
server {
  server_name project2.myserver.com;
  push_stream_bus_id project2;
  location /pub { ... }
  location ~ /sub-ev/(.*) { ... }
}

In this theoretical example http://project1.myserver.com/sub-ev/ch1 would receive messages published to http://project1.myserver.com/pub/ch1 but not to http://project2.myserver.com/pub/ch1

Currently I'm likely able (and need) to achieve this by: 1) prefixing channel names in urls prior to url generation in php. So when clients request sub urls (they don't compose them by theirselves) or php app needs a pub url, I add prefixes to every id in the url. 2) prefixing channel names by nginx regexp internally. Like replacing / to /prefix_ in $ids. Not sure if this is possible at all.

What would you recommend?

wandenberg commented 10 years ago

With the version on branch 0.4.x (and on the next release version) you will be able to create two different http blocks, each one with a shared memory zone. With that the servers will not receive messages from the other server. Something like that.

http { push_stream_shared_memory_size 100m project1;

server { server_name project1.myserver.com; location /pub { ... } location ~ /sub-ev/(.*) { ... } }

}

http {

push_stream_shared_memory_size 100m project2; server { server_name project2.myserver.com; location /pub { ... } location ~ /sub-ev/(.*) { ... } }

}

On Wed, Nov 6, 2013 at 12:29 AM, Alexey Kupershtokh < notifications@github.com> wrote:

Hello. I would like to use nginx-push-stream-module with a few separate projects and would like them use intersecting channel names. But I want to make the them isolated somehow by identifying a bus they publish/subscribe. A configuration example would look something like defining two hosts in the same nginx:

server { server_name project1.myserver.com; push_stream_busid project1; location /pub { ... } location ~ /sub-ev/(.) { ... } } server { server_name project2.myserver.com; push_stream_busid project2; location /pub { ... } location ~ /sub-ev/(.) { ... } }

In this theoretical example http://project1.myserver.com/sub-ev/ch1 would receive messages published to http://project1.myserver.com/pub/ch1 but not to http://project2.myserver.com/pub/ch1

Currently I'm likely able (and need) to achieve this by: 1) prefixing channel names in urls prior to url generation in php. So when clients request sub urls (they don't compose them by theirselves) or php app needs a pub url, I add prefixes to every id in the url. 2) prefixing channel names by nginx regexp internally. Like replacing /to /prefix_ in $ids. Not sure if this is possible at all.

What would you recommend?

— Reply to this email directly or view it on GitHubhttps://github.com/wandenberg/nginx-push-stream-module/issues/108 .

AlexeyKupershtokh commented 10 years ago

Cool, that seem exactly what I need. Are you planning to document this feature?

wandenberg commented 10 years ago

Yes. I'm updating the docs before the new release. This is why it wasn't released yet. ;)

On Wed, Nov 6, 2013 at 11:07 AM, Alexey Kupershtokh < notifications@github.com> wrote:

Cool, that seem exactly what I need. Are you planning to document this feature?

— Reply to this email directly or view it on GitHubhttps://github.com/wandenberg/nginx-push-stream-module/issues/108#issuecomment-27871589 .

AlexeyKupershtokh commented 10 years ago

Looking forward for the release :)