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

how to use different port #66

Closed windbug closed 11 years ago

windbug commented 11 years ago

first of all, im so sorry. i can not write english well.

generally, use example.com/pub -> publisher example.com/lp -> longpolling example.com/ws -> websocket

by the way. i wanna use example.com:11000 -> channels-stats example.com:11001 -> publisher example.com:11002 -> subscriber example.com:11003 -> longpolling example.com:11004 -> websocket

so i change nginx.conf like this

server { listen 11001 default_server; server_name pub.example.com;

    location / {
    # activate publisher mode for this location, with admin support
    push_stream_publisher admin;

    # query string based channel id
    set $push_stream_channel_id             $arg_id;

    # store messages in memory
    push_stream_store_messages              off;

    push_stream_keepalive                   on;

    # Message size limit
    # client_max_body_size MUST be equal to client_body_buffer_size or
    # you will be sorry.
    client_max_body_size                    32k;
    client_body_buffer_size                 32k;
}

}

and then, use pushstream.js,

ws -> status offline, 404 reponse

lp -> status offline, 405 (not allowed) xmlhttprequest cannot load http://example.com:11003/example?&_=113131. Origin http://example.com is not allowed by acc-control-allow-origin

refused to get ensafe header "Etag"

how can i use it? help plz...

wandenberg commented 11 years ago

Hi,

pushstream.js was not developed to this use case. To do that you will have to do a lot of work by yourself, but can be done.

Fist, to set different port number to each kind of location you have to set the push_stream_allowed_origins with the name of your server "example.com" as the example, to be possible the javascript has access, this is a security requirement.

Than you have to create a PushStream instance changing the urlPrefixLongpolling value to '/' and set the proper port number, and the modes to 'longpolling', as example:

new PushStream({
  port: 1234,
  modes: 'longpolling',
  urlPrefixLongpolling: '/'
});

You will have to control when you want to use websocket, eventsource, or longpolling, because the automatically fall back done by the pushstream.js only works when all locations are on same server configuration.

There is some special reason why you whant to change some locations for some servers changing the port number?

Regards, Wandenberg

windbug commented 11 years ago

ah...thx very much for fastest reply!! 감사합니다!!!!