slact / nchan

Fast, horizontally scalable, multiprocess pub/sub queuing server and proxy for HTTP, long-polling, Websockets and EventSource (SSE), powered by Nginx.
https://nchan.io/
Other
3.01k stars 292 forks source link

memstore_ipc_send_get_message: Assertion `data.shm_chid->len >= 1' failed. #555

Open stromnet opened 4 years ago

stromnet commented 4 years ago

On latest release:

Assertion failed: (data.shm_chid->len >= 1), function memstore_ipc_send_get_message, file ../nchan//src/store/memory/ipc-handlers.c, line 536.

when sending GET /sub without id in querystring and the following config options are present:

This crashes the worker. Minimal reproduce config:


worker_processes  3;
daemon off;

error_log /dev/stdout debug;

events {
  worker_connections  100;
}

http {
  include       mime.types;
  default_type  application/octet-stream;

  sendfile        on;

  keepalive_timeout  65;

  server {
    listen       80;
    server_name  localhost;
    location =/sub {
      nchan_subscriber;
      nchan_channel_id $arg_id;
      nchan_channel_id_split_delimiter ",";
    }

    location ~ /channel_events/(.+) {
      nchan_subscriber;
      nchan_channel_group meta;
      nchan_channel_id $1;
    }
  }
}
$ curl localhost:80/sub -v
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 80 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /sub HTTP/1.1
> Host: localhost
> User-Agent: curl/7.54.0
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server

Full output:

2020/03/09 14:05:36 [notice] 70542#0: using the "kqueue" event method
2020/03/09 14:05:36 [notice] 70542#0: nginx/1.17.6
2020/03/09 14:05:36 [notice] 70542#0: OS: Darwin 18.7.0
2020/03/09 14:05:36 [notice] 70542#0: hw.ncpu: 12
2020/03/09 14:05:36 [notice] 70542#0: net.inet.tcp.sendspace: 131072
2020/03/09 14:05:36 [notice] 70542#0: kern.ipc.somaxconn: 128
2020/03/09 14:05:36 [notice] 70542#0: getrlimit(RLIMIT_NOFILE): 256:9223372036854775807
2020/03/09 14:05:36 [notice] 70542#0: start worker processes
2020/03/09 14:05:36 [notice] 70542#0: start worker process 70543
2020/03/09 14:05:36 [notice] 70542#0: start worker process 70544
2020/03/09 14:05:36 [notice] 70542#0: start worker process 70545
2020/03/09 14:05:36 [debug] 70543#0: REAPER: start reaper memstore message with tick time of 5 sec
2020/03/09 14:05:36 [debug] 70543#0: REAPER: start reaper memstore nobuffer message with tick time of 2 sec
2020/03/09 14:05:36 [debug] 70544#0: REAPER: start reaper memstore message with tick time of 5 sec
2020/03/09 14:05:36 [debug] 70544#0: REAPER: start reaper memstore nobuffer message with tick time of 2 sec
2020/03/09 14:05:36 [debug] 70545#0: REAPER: start reaper memstore message with tick time of 5 sec
2020/03/09 14:05:36 [debug] 70545#0: REAPER: start reaper memstore nobuffer message with tick time of 2 sec
2020/03/09 14:05:36 [debug] 70544#0: REAPER: start reaper chanhead with tick time of 4 sec
2020/03/09 14:05:36 [debug] 70544#0: REAPER: start reaper chanhead churner with tick time of 10 sec
2020/03/09 14:05:36 [debug] 70543#0: REAPER: start reaper chanhead with tick time of 4 sec
2020/03/09 14:05:36 [debug] 70545#0: REAPER: start reaper chanhead with tick time of 4 sec
2020/03/09 14:05:36 [debug] 70545#0: REAPER: start reaper chanhead churner with tick time of 10 sec
2020/03/09 14:05:36 [debug] 70543#0: REAPER: start reaper chanhead churner with tick time of 10 sec
2020/03/09 14:05:36 [debug] 70544#0: MEMSTORE:01: init memstore worker pid:70544 slot:1 max workers :3 or 3
2020/03/09 14:05:36 [debug] 70544#0: MEMSTORE:01: found my procslot (ngx_process_slot 1, procslot 1)
2020/03/09 14:05:36 [debug] 70544#0: MEMSTORE:01: shm: 00007FDAEBF00000, shdata: 00000001133FC000
2020/03/09 14:05:36 [debug] 70544#0: WEBSOCKET_PUBLISHER:init WS publisher llist
2020/03/09 14:05:36 [debug] 70544#0: THINGCACHE: init fd_cache 00007FDAEE800120
2020/03/09 14:05:36 [notice] 70542#0: signal 23 (SIGIO) received from 70544
2020/03/09 14:05:36 [debug] 70545#0: MEMSTORE:02: init memstore worker pid:70545 slot:2 max workers :3 or 3
2020/03/09 14:05:36 [debug] 70545#0: MEMSTORE:02: found my procslot (ngx_process_slot 2, procslot 2)
2020/03/09 14:05:36 [debug] 70545#0: MEMSTORE:02: shm: 00007FDAEBF00000, shdata: 00000001133FC000
2020/03/09 14:05:36 [debug] 70545#0: WEBSOCKET_PUBLISHER:init WS publisher llist
2020/03/09 14:05:36 [debug] 70543#0: MEMSTORE:00: init memstore worker pid:70543 slot:0 max workers :3 or 3
2020/03/09 14:05:36 [debug] 70545#0: THINGCACHE: init fd_cache 00007FDAEBE001F0
2020/03/09 14:05:36 [debug] 70543#0: MEMSTORE:00: found my procslot (ngx_process_slot 0, procslot 0)
2020/03/09 14:05:36 [debug] 70543#0: MEMSTORE:00: shm: 00007FDAEBF00000, shdata: 00000001133FC000
2020/03/09 14:05:36 [debug] 70543#0: WEBSOCKET_PUBLISHER:init WS publisher llist
2020/03/09 14:05:36 [debug] 70543#0: THINGCACHE: init fd_cache 00007FDAEE000000
2020/03/09 14:05:36 [notice] 70542#0: signal 23 (SIGIO) received from 70543
2020/03/09 14:05:39 [debug] 70544#0: SUB:LONGPOLL:create for req 00007FDADC004E50
2020/03/09 14:05:39 [debug] 70544#0: SUB:LONGPOLL:00007FDAEBD00C90 created for request 00007FDADC004E50
2020/03/09 14:05:39 [debug] 70544#0: SPOOL:start SPOOLER 0000000000000000
2020/03/09 14:05:39 [debug] 70544#0: MEMSTORE:01: ensure chanhead ready: chanhead 00007FDAEBD00DE0, status 1, foreign_ipc_sub:0000000000000000
2020/03/09 14:05:39 [debug] 70544#0: MEMSTORE:01: ensure chanhead ready: request for  from 1 to 0
2020/03/09 14:05:39 [debug] 70544#0: IPC-HANDLERS(1):send subscribe to 0,
2020/03/09 14:05:39 [debug] 70544#0: IPC-HANDLERS(1):create shm_str 00000001133FF020 (data@ 00000001133FF030)
2020/03/09 14:05:39 [debug] 70544#0: IPC:IPC send alert code 0 to slot 0
2020/03/09 14:05:39 [debug] 70544#0: RBTREE:node not found
2020/03/09 14:05:39 [debug] 70544#0: RBTREE:created node 00007FDAEBD013F0
2020/03/09 14:05:39 [debug] 70543#0: IPC:IPC channel handler
2020/03/09 14:05:39 [debug] 70544#0: RBTREE:inserted node 00007FDAEBD013F0
2020/03/09 14:05:39 [debug] 70544#0: SUB:LONGPOLL:00007FDAEBD00C90 enqueue
2020/03/09 14:05:39 [debug] 70543#0: IPC:IPC read channel
2020/03/09 14:05:39 [debug] 70544#0: SUB:LONGPOLL:hodl request 00007FDADC004E50
2020/03/09 14:05:39 [debug] 70543#0: IPC-HANDLERS(0):received subscribe request for channel
2020/03/09 14:05:39 [debug] 70543#0: SPOOL:start SPOOLER 0000000000000000
2020/03/09 14:05:39 [debug] 70543#0: MEMSTORE:00: ensure chanhead ready: chanhead 00007FDAEBD00DB0, status 1, foreign_ipc_sub:0000000000000000
2020/03/09 14:05:39 [debug] 70543#0: MEMSTORE:00: Chanhead churn add 00007FDAEBD00DB0
2020/03/09 14:05:39 [debug] 70543#0: MEMSTORE:00: chanhead_gc max -1 count 0
2020/03/09 14:05:39 [debug] 70543#0: MEMSTORE:00: message GC results: started with 0, walked 0, deleted 0 msgs
2020/03/09 14:05:39 [debug] 70543#0: MEMSTORE:00: not ready to reap 00007FDAEBD00DB0 , 5 sec left
2020/03/09 14:05:39 [debug] 70543#0: REAPER: reap chanhead churner 00007FDAEBD00DB0 later (waiting to be reaped: 1)
2020/03/09 14:05:39 [debug] 70543#0: REAPER: reap chanhead churner again later (remaining: 1)
2020/03/09 14:05:39 [debug] 70543#0: SUB:INTERNAL:00007FDAEBE00490 create memstore-ipc with privdata 00007FDAEBE005A8
2020/03/09 14:05:39 [debug] 70543#0: SUB:MEM-IPC:00007FDAEBE00490 () memstore-ipc subscriber created with privdata 00007FDAEBE005A8
2020/03/09 14:05:39 [debug] 70543#0: SUB:INTERNAL:00007FDAEBE00490 (memstore-ipc) enqueue
2020/03/09 14:05:39 [debug] 70543#0: SUB:MEM-IPC:00007FDAEBE00490 () memstore subsriber enqueued ok
2020/03/09 14:05:39 [debug] 70543#0: SUB:INTERNAL:00007FDAEBE00490 set dequeue handler to 000000010C0FC490
2020/03/09 14:05:39 [debug] 70543#0: SUB:INTERNAL:00007FDAEBE00490 set dequeue handler data to 000000010C0FC490
2020/03/09 14:05:39 [debug] 70543#0: SUB:INTERNAL:00007FDAEBE00490 status 204
2020/03/09 14:05:39 [debug] 70543#0: IPC:IPC send alert code 1 to slot 1
2020/03/09 14:05:39 [debug] 70543#0: IPC-HANDLERS(0):sent subscribe reply for channel  to 1
2020/03/09 14:05:39 [debug] 70543#0: IPC:IPC read channel
2020/03/09 14:05:39 [debug] 70544#0: IPC:IPC channel handler
2020/03/09 14:05:39 [debug] 70544#0: IPC:IPC read channel
2020/03/09 14:05:39 [debug] 70544#0: IPC-HANDLERS(1):received subscribe reply for channel
2020/03/09 14:05:39 [debug] 70544#0: MEMSTORE:01: ensure chanhead ready: chanhead 00007FDAEBD00DE0, status 2, foreign_ipc_sub:0000000000000000
2020/03/09 14:05:39 [debug] 70544#0: IPC-HANDLERS(1):receive subscribe proceed to do ipc_sub stuff
2020/03/09 14:05:39 [debug] 70544#0: SPOOL:00007FDAEBD01418 fetch msg 0:0 for channel
2020/03/09 14:05:39 [debug] 70544#0: MEMSTORE:01: ensure chanhead ready: chanhead 00007FDAEBD00DE0, status 4, foreign_ipc_sub:00007FDAEBE00490
2020/03/09 14:05:39 [debug] 70544#0: IPC-HANDLERS(1):create shm_str 00000001133FF030 (data@ 00000001133FF040)
2020/03/09 14:05:39 [debug] 70544#0: IPC-HANDLERS(1):IPC: send get message from 0 ch
Assertion failed: (data.shm_chid->len >= 1), function memstore_ipc_send_get_message, file ../nchan//src/store/memory/ipc-handlers.c, line 536.
2020/03/09 14:05:39 [notice] 70542#0: signal 20 (SIGCHLD) received from 70544
2020/03/09 14:05:39 [alert] 70542#0: worker process 70544 exited on signal 6
2020/03/09 14:05:39 [notice] 70542#0: start worker process 70547
2020/03/09 14:05:39 [notice] 70542#0: signal 23 (SIGIO) received
2020/03/09 14:05:39 [notice] 70542#0: signal 23 (SIGIO) received
2020/03/09 14:05:39 [debug] 70547#0: REAPER: start reaper memstore message with tick time of 5 sec
2020/03/09 14:05:39 [debug] 70547#0: REAPER: start reaper memstore nobuffer message with tick time of 2 sec
2020/03/09 14:05:39 [debug] 70547#0: REAPER: start reaper chanhead with tick time of 4 sec
2020/03/09 14:05:39 [debug] 70547#0: REAPER: start reaper chanhead churner with tick time of 10 sec
2020/03/09 14:05:39 [debug] 70547#0: MEMSTORE:01: init memstore worker pid:70547 slot:1 max workers :3 or 3
2020/03/09 14:05:39 [debug] 70547#0: MEMSTORE:01: found my procslot (ngx_process_slot 1, procslot 1)
2020/03/09 14:05:39 [debug] 70547#0: MEMSTORE:01: shm: 00007FDAEBF00000, shdata: 00000001133FC000
2020/03/09 14:05:39 [debug] 70547#0: WEBSOCKET_PUBLISHER:init WS publisher llist
2020/03/09 14:05:39 [debug] 70547#0: THINGCACHE: init fd_cache 00007FDAEBD00CE0
^C2020/03/09 14:05:41 [notice] 70542#0: signal 2 (SIGINT) received from 520, exiting
2020/03/09 14:05:41 [notice] 70543#0: signal 2 (SIGINT) received from 520, exiting
2020/03/09 14:05:41 [notice] 70545#0: signal 2 (SIGINT) received from 520, exiting
2020/03/09 14:05:41 [notice] 70547#0: signal 2 (SIGINT) received from 520, exiting
2020/03/09 14:05:41 [info] 70543#0: kevent() failed (4: Interrupted system call)
2020/03/09 14:05:41 [notice] 70543#0: exiting
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: exit worker 70543  (slot 0)
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: Chanhead gc add 00007FDAEBD00DB0 : exit worker
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: Chanhead churn withdraw 00007FDAEBD00DB0
2020/03/09 14:05:41 [debug] 70543#0: REAPER: withdraw chanhead churner 00007FDAEBD00DB0
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: chanhead_gc max -1 count 0
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: message GC results: started with 0, walked 0, deleted 0 msgs
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: not ready to reap , 5 sec left
2020/03/09 14:05:41 [debug] 70543#0: REAPER: reap chanhead 00007FDAEBD00DB0 later (waiting to be reaped: 1)
2020/03/09 14:05:41 [debug] 70543#0: REAPER: reap chanhead again later (remaining: 1)
2020/03/09 14:05:41 [notice] 70543#0: nchan: 1 channel remains at ex2020/03/09 14:05:41 [info] 70547#0: kevent() failed (4: Interrupted system call)
2020/03/09 14:05:41 [info] 70545#0: kevent() failed (4: Interrupted system call)
it
2020/03/09 14:05:41 [notice] 70545#0: exiting
2020/03/09 14:05:41 [debug] 70543#0: REAPER: chanhead churner scan max notready 0
2020/03/09 14:05:41 [notice] 70547#0: exiting
2020/03/09 14:05:41 [debug] 70543#0: REAPER: stopped reaper chanhead churner
2020/03/09 14:05:41 [debug] 70543#0: REAPER: chanhead scan max notready 0
2020/03/09 14:05:41 [debug] 70545#0: MEMSTORE:02: exit worker 70545  (slot 2)
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: chanhead_gc max -1 count 0
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: message GC results: started with 0, walked 0, deleted 0 msgs
2020/03/09 14:05:41 [debug] 70545#0: REAPER: chanhead churner scan max notready 0
2020/03/09 14:05:41 [debug] 70545#0: REAPER: stopped reaper chanhead churner
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: chanhead_gc max 0 count 0
2020/03/09 14:05:41 [debug] 70545#0: REAPER: chanhead scan max notready 0
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: message GC results: started with 0, walked 0, deleted 0 msgs
2020/03/09 14:05:41 [debug] 70545#0: REAPER: stopped reaper chanhead
2020/03/09 14:05:41 [debug] 70547#0: MEMSTORE:01: exit worker 70547  (slot 1)
2020/03/09 14:05:41 [debug] 70543#0: SPOOL:spool 00007FDAEBD00E88 (-1:0) (subs: 1) respond with msg 0000000000000000 or code 410
2020/03/09 14:05:41 [debug] 70547#0: REAPER: chanhead churner scan max notready 0
2020/03/09 14:05:41 [debug] 70545#0: REAPER: memstore nobuffer message scan max notready 0
2020/03/09 14:05:41 [debug] 70543#0: SUB:INTERNAL:00007FDAEBE00490 status 410
2020/03/09 14:05:41 [debug] 70547#0: REAPER: stopped reaper chanhead churner
2020/03/09 14:05:41 [debug] 70547#0: REAPER: chanhead scan max notready 0
2020/03/09 14:05:41 [debug] 70543#0: IPC-HANDLERS(0):IPC: send publish status to 1 ch
2020/03/09 14:05:41 [debug] 70545#0: REAPER: stopped reaper memstore nobuffer message
2020/03/09 14:05:41 [debug] 70547#0: REAPER: stopped reaper chanhead
2020/03/09 14:05:41 [debug] 70545#0: REAPER: memstore message scan max notready 0
2020/03/09 14:05:41 [debug] 70547#0: REAPER: memstore nobuffer message scan max notready 0
2020/03/09 14:05:41 [debug] 70543#0: IPC-HANDLERS(0):create shm_str 00000001133FF040 (data@ 00000001133FF050)
2020/03/09 14:05:41 [debug] 70547#0: REAPER: stopped reaper memstore nobuffer message
2020/03/09 14:05:41 [debug] 70543#0: IPC:IPC send alert code 7 to slot 1
2020/03/09 14:05:41 [debug] 70547#0: REAPER: memstore message scan max notready 0
2020/03/09 14:05:41 [debug] 70547#0: REAPER: stopped reaper memstore message
2020/03/09 14:05:41 [debug] 70543#0: SUB:INTERNAL:00007FDAEBE00490 (memstore-ipc) dequeue sub
2020/03/09 14:05:41 [debug] 70543#0: SUB:MEM-IPC:00007FDAEBE00490 () memstore subscriber dequeue: notify owner
2020/03/09 14:05:41 [debug] 70543#0: IPC-HANDLERS(0):send unsubscribed to 1
2020/03/09 14:05:41 [debug] 70543#0: IPC-HANDLERS(0):create shm_str 00000001133FF050 (data@ 00000001133FF060)
2020/03/09 14:05:41 [debu2020/03/09 14:05:41 [debug] 70547#0: MEMSTORE:GROUPS: empties rbtree
g] 70545#0: REAPER: stopped reaper memstore message
2020/03/09 14:05:41 [debug] 70543#0: IPC:IPC send alert code 4 to slot 1
2020/03/09 14:05:41 [debug] 70543#0: SUB:MEM-IPC:00007FDAEBE00490 () destroy
2020/03/09 14:05:41 [debug] 70543#0: SPOOL:sub 00007FDAEBE00490 dequeue callback
2020/03/09 14:05:41 [debug] 70545#0: MEMSTORE:GROUPS: empties rbtree
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: Chanhead gc add 00007FDAEBD00DB0 : sub count == 0 after spooler dequeue
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: gc_add chanhead : already added
2020/03/09 14:05:41 [debug] 70543#0: SUB:INTERNAL:00007FDAEBE00490 (memstore-ipc) destroy
2020/03/09 14:05:41 [debug] 70543#0: SPOOL:stopped 0 spools in SPOOLER 0000000000000000
2020/03/09 14:05:41 [debug] 70547#0: IPC:start closing
2020/03/09 14:05:41 [debug] 70547#0: IPC:done closing
2020/03/09 14:05:41 [debug] 70547#0: THINGCACHE: shutdown fd_cache 00007FDAEBD00CE0
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:00: chanhead 00007FDAEBD00DB0 () is empty and expired. DELETE.
2020/03/09 14:05:41 [debug] 70543#0: REAPER: reaped chanhead 00007FDAEBD00DB0 (waiting to be reaped: 0)
2020/03/09 14:05:41 [debug] 70543#0: REAPER: stopped reaper chanhead
2020/03/09 14:05:41 [debug] 70543#0: REAPER: memstore nobuffer message scan max notready 0
2020/03/09 14:05:41 [debug] 70543#0: REAPER: stopped reaper memstore nobuffer message
2020/03/09 14:05:41 [debug] 70543#0: REAPER: memstore message scan max notready 0
2020/03/09 14:05:41 [debug] 70543#0: REAPER: stopped reaper memstore message
2020/03/09 14:05:41 [debug] 70543#0: MEMSTORE:GROUPS: empties rbtree
2020/03/09 14:05:41 [debug] 70545#0: IPC:start closing
2020/03/09 14:05:41 [notice] 70547#0: exit
2020/03/09 14:05:41 [debug] 70545#0: IPC:done closing
2020/03/09 14:05:41 [debug] 70543#0: IPC:start closing
2020/03/09 14:05:41 [debug] 70545#0: THINGCACHE: shutdown fd_cache 00007FDAEBE001F0
2020/03/09 14:05:41 [notice] 70545#0: exit
2020/03/09 14:05:41 [debug] 70543#0: IPC:done closing
2020/03/09 14:05:41 [debug] 70543#0: THINGCACHE: shutdown fd_cache 00007FDAEE000000
2020/03/09 14:05:41 [notice] 70542#0: signal 20 (SIGCHLD) received from 70547
2020/03/09 14:05:41 [notice] 70542#0: worker process 70547 exited with code 0
2020/03/09 14:05:41 [notice] 70543#0: exit
2020/03/09 14:05:41 [notice] 70542#0: signal 23 (SIGIO) received
2020/03/09 14:05:41 [notice] 70542#0: signal 20 (SIGCHLD) received from 70545
2020/03/09 14:05:41 [notice] 70542#0: worker process 70545 exited with code 0
2020/03/09 14:05:41 [notice] 70542#0: signal 23 (SIGIO) received
2020/03/09 14:05:41 [notice] 70542#0: signal 20 (SIGCHLD) received from 70543
2020/03/09 14:05:41 [notice] 70542#0: worker process 70543 exited with code 0
2020/03/09 14:05:41 [notice] 70542#0: exit
2020/03/09 14:05:41 [debug] 70542#0: MEMSTORE:01: exit master from pid 70542
2020/03/09 14:05:41 [debug] 70542#0: IPC:start closing
2020/03/09 14:05:41 [debug] 70542#0: IPC:done closing
slact commented 4 years ago

I'm unable to reproduce the crash with the test case you've provided. What version of Nchan are you using?

stromnet commented 4 years ago

This was trigged with nchan 1.2.6 from 4a4e42967fd37c1cb57e2142632f6180dee49253, and nginx 1.17.6. I manage to repeat it every time.

The actual output from above was from MacOS, but I've originally discovered the issue on a Linux build (in docker container).

I slapped together a more minimal Dockerfile (the full one builds with openresty and other stuff), I can reproduce it there as well:

FROM registry.access.redhat.com/ubi8/ubi-minimal:latest AS base_image
RUN microdnf update && \
    microdnf install pcre zlib curl libgcc gcc \
    make \
    git \
    pcre-devel \
    zlib-devel tar patch perl && \
    microdnf clean all

ARG NGINX_VERSION=1.17.6
ARG NCHAN_VERSION=1.2.6

ARG NGINX_URL='http://nginx.org/download'
ARG NGINX_PREFIX=/opt/nginx
ARG NCHAN_URL='https://github.com/slact/nchan/archive'

WORKDIR /src
RUN curl -o /src/nginx-$NGINX_VERSION.tar.gz $NGINX_URL/nginx-$NGINX_VERSION.tar.gz
RUN curl -Lfo /src/nchan-$NCHAN_VERSION.tar.gz $NCHAN_URL/v$NCHAN_VERSION.tar.gz

WORKDIR /build
RUN tar xzf /src/nginx-$NGINX_VERSION.tar.gz --strip-components=1 && \
    mkdir -p nchan && tar xzf /src/nchan-$NCHAN_VERSION.tar.gz --strip-components=1 -C ./nchan

RUN ./configure \
     --with-cc-opt=-Wno-error \
     --prefix=$NGINX_PREFIX \
     --add-module=./nchan/ \
   && make -j$(nproc) \
   && make install

RUN echo "\
worker_processes  3; \
daemon off; \
error_log /dev/stdout debug;\
events {\
  worker_connections  100;\
}\
http {\
  server {\
    listen       80;\
    server_name  localhost;\
    location =/sub {\
      nchan_subscriber;\
      nchan_channel_id \$arg_id;\
      nchan_channel_id_split_delimiter ",";\
    }\
\
    location ~ /channel_events/(.+) {\
      nchan_subscriber;\
      nchan_channel_group meta;\
      nchan_channel_id \$1;\
    }\
  }\
}\
" > /opt/nginx/conf/nginx.conf

WORKDIR /opt/nginx
CMD ./sbin/nginx -c conf/nginx.conf
EXPOSE 80
docker run --rm -it -p 80:80 nginx-nchan-test

curl localhost:80/sub -v

The first run it actually didn't reproduce, but on the second it did.