如何在Nginxconfiguration文件中混合使用variables和string?
我有一个如下所示的configuration文件:
server { listen 80; server_name example.org; root /var/www/comet; index index.htm; default_type text/plain; location /publish { push_stream_publisher admin; set $push_stream_channel_id $arg_id; } location /sub { push_stream_subscriber long-polling; set $callback "${arg_callback}({\"id\":~id~,\"data\":~text~});"; push_stream_message_template $callback; set $push_stream_channels_path "/channel1"; } }
这是一个推送服务器,它应该推送消息到客户端,取决于他们传递给callback参数。
也就是说,如果用户请求http://example.org/sub?callback=call&id=blah并给他们发送消息,它应该读取call({"id":0, "data":"blah"});
上面的代码输出文字variables名称
tangrs@~ $ curl "http://example.org/sub?id=woo&callback=call" -D - && echo HTTP/1.1 200 OK Server: nginx/1.0.11 Date: Thu, 12 Jan 2012 04:55:38 GMT Content-Type: text/plain Last-Modified: Thu, 12 Jan 2012 04:55:38 GMT Connection: close Transfer-Encoding: chunked Etag: 0 $callback
有谁知道如何连接Nginx的configuration文件中的string?
将string存储在另一个variables(比如$ string)中,并执行以下操作:
设置$ callback $ arg_callback $ string;