#user nobody;
worker_processes 3;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location ~ \.html {
# lua_code_cache off;
content_by_lua_block {
--ngx.print("{'errno':9001}")
local t1 = ngx.now()
res1, res2, res3, res4, res5, res6 = ngx.location.capture_multi{
{ "/bar", { method = ngx.HTTP_POST, body = "hello" } },
{ "/bar2", { method = ngx.HTTP_POST, body = "hello" } },
{ "/bar3", { method = ngx.HTTP_POST, body = "hello" } },
{ "/bar4", { method = ngx.HTTP_POST, body = "hello" } },
{ "/bar5", { method = ngx.HTTP_POST, body = "hello" } },
{ "/bar", { method = ngx.HTTP_POST, body = "hello" } },
}
--res1 = ngx.location.capture(
-- '/bar',
-- { method = ngx.HTTP_POST, body = 'hello' }
-- )
--res2 = ngx.location.capture(
-- '/bar2',
-- { method = ngx.HTTP_POST, body = 'hello' }
-- )
--res4 = ngx.location.capture(
-- '/bar4',
-- { method = ngx.HTTP_POST, body = 'hello' }
-- )
--res3 = ngx.location.capture(
-- '/bar3',
-- { method = ngx.HTTP_POST, body = 'hello' }
-- )
--res5 = ngx.location.capture(
-- '/bar5',
-- { method = ngx.HTTP_POST, body = 'hello' }
-- )
--res6 = ngx.location.capture(
-- '/bar',
-- { method = ngx.HTTP_POST, body = 'hello' }
-- )
local t2 = ngx.now()
ngx.print('--t1----'..t2..'----') -- 输出1487053211.321,1487053211.321
ngx.print("<br>")
ngx.print('--t2----'..t2..'----') -- 输出1487053211.321,1487053211.321
ngx.print("<br>")
ngx.print('------'..t2-t1..'----') -- 输出1487053211.321,1487053211.321
ngx.print("<br>")
ngx.print(res1.body)
ngx.print("----------")
ngx.print("<br>")
ngx.print(res2.body)
ngx.print("----------")
ngx.print("<br>")
ngx.print(res3.body)
ngx.print("----------")
ngx.print("<br>")
ngx.print(res4.body)
ngx.print("----------")
ngx.print("<br>")
ngx.print(res5.body)
ngx.print("----------")
ngx.print("<br>")
--ngx.print(res6.body)
ngx.print("----------")
ngx.print("<br>")
return
}
} #error_page 404 /404.html;
location /bar {
content_by_lua_block {
-- ngx.sleep(1)
--os.execute("sleep " .. 1)
local x = 0
for i = 1, 100000000 do
--for i = 1, 10000000000 do
x = x + i
end
ngx.say("ok")
}
}
location /bar2 {
content_by_lua_block {
--ngx.sleep(1)
--os.execute("sleep " .. 1)
local x = 0
--for i = 1, 10000 do
for i = 1, 100000000 do
--for i = 1, 10000000000 do
x = x + i
end
ngx.say("ok2")
}
}
location /bar3 {
content_by_lua_block {
--ngx.sleep(1)
local x = 0
--for i = 1, 10000 do
for i = 1, 100000000 do
--for i = 1, 10000000000 do
x = x + i
end
ngx.say("ok3")
}
}
location /bar4 {
content_by_lua_block {
--ngx.sleep(1)
--os.execute("sleep " .. 1)
local x = 0
--for i = 1, 10000 do
for i = 1, 100000000 do
--for i = 1, 10000000000 do
x = x + i
end
ngx.say("ok4")
}
}
location /bar5 {
content_by_lua_block {
--ngx.sleep(1)
--os.execute("sleep " .. 1)
local x = 0
--for i = 1, 10000 do
for i = 1, 100000000 do
--for i = 1, 10000000000 do
x = x + i
end
ngx.say("ok5")
}
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}