2 3 4 5 6 wget http://luajit.org/download/LuaJIT-2.0.2.tar.gz tar zxvf LuaJIT-2.0.2.tar.gz make make install PREFIX=/usr/local/luajit2.02 echo /usr/local/luajit2.02/lib /etc/ld.so.conf.d/luajit.conf export LUAJIT_LIB=/usr/local/luajit2.02/...
1 git clone https://github.com/liseen/lua-resty-http.git Nginx配置: 1 2 3 4 5 6 7 8 http { llua_package_path /path/to/lua-resty-http/lib/?.lua;;; server { location /test { content_by_lua_file /usr/local/nginx/conf/lua/proxy.lua; } } Proxy...
location / { set $bindip ; content_by_lua_file /usr/local/nginx/lua/proxy.lua; } location /proxy { proxy_pass http://$host$request_uri; proxy_bind $bindip; } local action = ngx.var.request_methodif action == POST then method = ngx.HTTP_POS...
1.rewrite使用break结,使用last会对server标签重新发起请求 location /a/ { rewrite ^/a/(.*)$ /b/$1 break; proxy_pass http://www.it.net.cn; } 2.proxy_pass结尾添加/会丢弃路径目录,如下访问/a/test.html会代理到/test.html location /a/ { rewrite ^/a...
nginx 的官方注释是这样的: 1 2 3 4 5 last stops processing the current set of ngx_http_rewrite_module directives followed by a search for a new location matching the changed URI; break stops processing the current set of ngx_http_rewrite_m...
SERVER_NAME对应Nginx配置文件中的server_name,通过fastcgi_param设置,如域名指向到IP而不在nginx中设置对应的server_name,PHP取SERVER_NAME为空,如果有多个server_name,取第一个。 1 2 server_name www.haiyun.me; fastcgi_param SERVER_NAME $server_...
listen 80 default; server_name ~^(.*?\.)*(?domain.[^\.]+?\..[^\.|\d]+?)$; access_log /home/wwwlogs/$domain main; 参考: http://nginx.org/en/docs/http/server_names.html#regex_names...
Nginx与PHP通信使用TCP连接会造成太多TIME_WAIT及浪费新建连接开销,Nginx新版本增加了对后端启用keepalive功能,有效提高服务器性能。 配置: http { upstream fastcgi_backend { server 127.0.0.1:9000; keepalive 60; } } server { location ~ .*\.php$ {...
#centos6: rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm #centos5: rpm -ivh http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm 或自添加: [nginx...
Nginx配置80和443端口在同一server段时不要这样设置: listen 80; listen 443; ssl on; 应该在443端口后添加ssl: listen 80; listen 443 ssl; 有时后端PHP要判断HTTPS: fastcgi_param HTTPS $https if_not_empty;...