/
nginx-async.conf
128 lines (106 loc) · 3.7 KB
/
nginx-async.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# this nginx configuration file is for demonstration purpose only
user nobody;
worker_processes 2;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
sendfile on;
haskell load /var/lib/nginx/test_tsung.so;
haskell_run_service getUrlService $hs_service_ya "http://ya.ru";
haskell_run_service getUrlService $hs_service_httpbin "http://httpbin.org";
server {
listen 8010;
server_name main;
error_log /tmp/nginx-test-haskell-error.log;
access_log /tmp/nginx-test-haskell-access.log;
location / {
haskell_run_async getUrl $hs_async_ya
"http://ya.ru";
haskell_run_async getUrl $hs_async_httpbin
"http://httpbin.org";
haskell_run_async getUrl $hs_async_hackage
"http://hackage.haskell.org";
echo "------> YA.RU:\n\n$hs_async_ya\n";
echo "------> HTTPBIN.ORG:\n\n$hs_async_httpbin\n";
echo "------> HACKAGE.HASKELL.ORG:\n\n$hs_async_hackage";
}
location /rewrite {
#echo "HERE";
rewrite ^ / last;
}
location /delay {
haskell_run_async delay $hs_async_elapsed $arg_a;
echo "Elapsed $hs_async_elapsed seconds";
}
location /rb {
client_body_buffer_size 100k;
haskell_run_async_on_request_body reqBody $hs_rb noarg;
haskell_run_async_on_request_body reqFld $hs_rb_fld $arg_a;
haskell_run_async_on_request_body reqHead $hs_rb_head $arg_a;
echo ">>> BODY\n";
echo $hs_rb;
echo ">>> BODY HEAD $arg_a\n";
echo $hs_rb_head;
echo ">>> FIELD $arg_a\n";
echo $hs_rb_fld;
}
location /rb/touch {
client_body_buffer_size 100k;
haskell_run_async_on_request_body reqBodyTouch $hs_dummy noarg;
if ($request_body) {
echo $request_body;
break;
}
echo Fail;
}
location /async {
haskell_run_async getUrl $hs_async_test "http://localhost:8020/";
echo -n $hs_async_test;
}
location /asyncConnTimeout {
haskell_run_async unsafeGetUrlConnTimeout $hs_async_test
"http://localhost:8020/";
echo -n $hs_async_test;
}
location /ya {
echo $hs_service_ya;
}
location /httpbin {
echo $hs_service_httpbin;
}
location /1 {
haskell_run_async getUrl1 $hs_async_ya
"http://ya.ru";
haskell_run_async getUrl1 $hs_async_httpbin
"http://httpbin.org";
haskell_run_async getUrl1 $hs_async_hackage
"http://hackage.haskell.org";
echo "------> YA.RU:\n\n$hs_async_ya\n";
echo "------> HTTPBIN.ORG:\n\n$hs_async_httpbin\n";
echo "------> HACKAGE.HASKELL.ORG:\n\n$hs_async_hackage";
}
location /delay1 {
haskell_run_async delay1 $hs_async_elapsed $arg_a;
echo "Elapsed $hs_async_elapsed seconds";
}
location /io {
haskell_run getIOValue $hs_val "";
echo $hs_val;
}
location /content {
haskell_async_content getUrlContent "http://httpbin.org";
}
}
server {
listen 8020;
server_name backend;
error_log /tmp/nginx-test-haskell-error.log;
access_log off;
location / {
echo "Hello main!";
}
}
}
# vim: ft=nginx