# Config help needed to create long-polling location

**URL:** <https://www.ruby-forum.com/t/config-help-needed-to-create-long-polling-location/188210>\
**Category:** NGINX\
**Created:** [May 7, 2010, 6:54pm UTC](https://www.ruby-forum.com/t/config-help-needed-to-create-long-polling-location/188210 "2010-05-07T18:54:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [May 7, 2010, 6:54pm UTC](https://www.ruby-forum.com/t/config-help-needed-to-create-long-polling-location/188210/1 "2010-05-07T18:54:48Z")

</div>

Hi All,

I’m trying to use the long polling module. I got it compiled, installed  
and running:-

ian@titan:~$ nginx -V  
nginx version: nginx/0.7.65  
built by gcc 4.3.3 (Ubuntu 4.3.3-5ubuntu4)  
configure arguments: --with-openssl=/usr/lib/ssl/ --sbin-path=/usr/sbin  
–conf-path=/etc/nginx/nginx.conf  
–add-module=/home/ian/sources/nginx\_http\_push\_module-0.69  
ian@titan:~$

But I can’t get it configured properly. The address to write messages  
to, appears not to exist whatever I do.

The key part of the configuration is this:-

server {  
listen 80;  
server\_name coachmaster.titan.hcs;  
root /home/ian/websites/coachmaster;  
index index.php index.html index.htm;  
error\_page 500 502 503 504 /50x.html;  
location = /50x.html {  
root /var/www/nginx-default;  
}  
location ~ .php$ {  
fastcgi\_pass 127.0.0.1:9000;  
include /etc/nginx/fastcgi\_params;  
}  
# now to configure the long polling  
push\_store\_messages on;  
location /publish {  
push\_publisher;  
set $push\_channel\_id $arg\_id;  
push\_message\_timeout 5m;  
push\_max\_message\_buffer\_length 10;  
push\_min\_message\_recipients 0;  
}  
# public long-polling endpoint  
location /activity {  
push\_subscriber;  
push\_subscriber\_concurrency broadcast;  
set $push\_channel\_id $arg\_id;  
default\_type text/plain;  
}  
}

When I post to the /publish location I get a 404 error. Always. When I  
“get” from a file that exists, I get the file content.  
When I post to a .php that exists, it gets run and its output is  
returned, so I’m fairly confident that the trouble is in the config file  
or my understanding, not the php.

This is the test script:-

\<?php $host = $\_SERVER['HTTP\_HOST']; $url = "http://$host/publish?id=1234"; $ch = curl\_init($url); curl\_setopt($ch, CURLOPT\_HTTPHEADER, Array("Content-Type: text/json")); curl\_setopt($ch, CURLOPT\_HTTPHEADER, Array("Accept: text/json")); curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, true); // read data curl\_setopt($ch, CURLOPT\_POST, true); // do a post curl\_setopt($ch, CURLOPT\_POSTFIELDS, 'A test message'); $rec\_data = curl\_exec($ch); echo "Result\n"; echo $rec\_data; ?\>

This is the reply:-

Result

404 Not Found
# Not Found

The requested URL /publish was not found on this server.

If you are wondering why I should do the post from php, it is because I  
want to log the info posted as well, and  
check that the poster is logged in properly, neither of which I can do  
in JavaScript.

I would be very grateful if some kind person can spot what I’m doing  
wrong - before I tear out my remaining hair!

Regards

Ian

---

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [May 8, 2010, 3:41pm UTC](https://www.ruby-forum.com/t/config-help-needed-to-create-long-polling-location/188210/2 "2010-05-08T15:41:26Z")

</div>

On 07/05/2010 17:54, Ian H. wrote:  
Big snip.

OK. This is embarrassing.

There is nothing the matter with the config I posted.

I was not testing on the machine I had set up!

Note to self - don’t stay up half election night - and then expect to  
think straight the next morning!

Regards

Ian
