配置命令
directives : content: loc,if in loc
- hi,default: ""
example:
location = /hello {
hi cpp/hello.so ;
}
directives : content: http,srv,loc,if in loc ,if in srv
- hi_need_tokens,default: on
example:
hi_need_tokens on|off;
directives : content: http,srv,loc,if in loc ,if in srv
- hi_cache_method,default: GET
example:
hi_cache_method GET|POST|PUT|HEAD;
directives : content: http,srv,loc,if in loc ,if in srv
- hi_need_cache,default: on
example:
hi_need_cache on|off;
directives : content: http,srv,loc,if in loc ,if in srv
- hi_cache_size,default: 10
example:
hi_cache_size 10;
directives : content: http,srv,loc,if in loc ,if in srv
- hi_cache_expires,default: 300s
example:
hi_cache_expires 300s;
directives : content: http,srv,loc,if in loc ,if in srv
- hi_need_kvdb,default: off
example:
hi_need_kvdb on|off;
directives : content: http,srv,loc,if in loc ,if in srv
- hi_kvdb_size,default: 10
example:
hi_kvdb_size 10;
directives : content: http,srv,loc,if in loc ,if in srv
- hi_kvdb_expires,default: 300s
example:
hi_kvdb_expires 300s;
directives : content: http,srv,loc,if in loc ,if in srv
- hi_need_headers,default: off
example:
hi_need_headers on|off;
directives : content: http,srv,loc,if in loc ,if in srv
- hi_need_cookies,default: off
example:
hi_need_cookies on|off;
directives : content: http,srv,loc,if in loc ,if in srv
- hi_need_session,default: off
example:
hi_need_session on|off;
directives : content: http,srv,loc,if in loc ,if in srv
- hi_session_expires,default: 300s
example:
hi_session_expires 300s;
directives : content: http,srv ,if in srv
- hi_redis_host,default: ""
example:
hi_redis_host 127.0.0.1;
directives : content: http,srv,if in srv
- hi_redis_port,default: 0
example:
hi_redis_port 6379;
directives : content: loc,if in loc
- hi_python_content,default: ""
example:
location = /pyecho {
hi_python_content "hi_res.status(200)\nhi_res.content('hello,world')" ;
}
directives : content: loc,if in loc
- hi_python_script,default: ""
example:
location ~ \.py$ {
hi_python_script python;
}
or
location / {
hi_python_script python/index.py;
}
directives : content: http,srv,if in srv
- hi_lua_package_path,default: ""
example:
hi_lua_package_path '/usr/local/nginx/lua/?.lua;';
directives : content: http,srv,if in srv
- hi_lua_package_cpath,default: ""
example:
hi_lua_package_cpath '/usr/local/nginx/lua/?.so;';
directives : content: loc,if in loc
- hi_lua_content,default: ""
example:
location = /luaecho {
hi_lua_content "hi_res:status(200)\nhi_res:content('hello,world')" ;
}
directives : content: loc,if in loc
- hi_lua_script,default: ""
example:
location ~ \.lua$ {
hi_lua_script lua;
}
or
location / {
hi_lua_script lua/index.lua;
}
directives : content: http,srv,if in srv
- hi_duktape_package_path,default: ""
example:
hi_duktape_package_path '/usr/local/nginx/duktape/package';
directives : content: http,srv,if in srv
- hi_duktape_package_cpath,default: ""
example:
hi_duktape_package_cpath '/usr/local/nginx/duktape/package';
directives : content: loc,if in loc
- hi_duktape_content,default: ""
example:
location = /luaecho {
hi_duktape_content "hi_res:status(200);hi_res:content('hello,world')" ;
}
directives : content: loc,if in loc
- hi_duktape_script,default: ""
example:
location ~ \.lua$ {
hi_duktape_script duktape;
}
or
location / {
hi_duktape_script duktape/index.js;
}
directives : content: http,srv,if in srv
- hi_java_classpath,default:"-Djava.class.path=."
example:
hi_java_classpath "-Djava.class.path=.:/usr/local/nginx/java:/usr/local/nginx/java/hi-nginx-java.jar";
directives : content: http,srv,if in srv
- hi_java_options,default:"-server -d64 -Xmx1G -Xms1G -Xmn256m"
example:
hi_java_options "-server -d64 -Xmx3G -Xms3G -Xmn768m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseNUMA -XX:+CMSParallelRemarkEnabled -XX:MaxTenuringThreshold=15 -XX:MaxGCPauseMillis=30 -XX:GCPauseIntervalMillis=150 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=15 -Dfml.ignorePatchDiscrepancies=true -Dfml.ignoreInvalidMinecraftCertificates=true -XX:+UseFastAccessorMethods -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts -XX:ReservedCodeCacheSize=2048m -XX:+UseCodeCacheFlushing -XX:SoftRefLRUPolicyMSPerMB=10000 -XX:ParallelGCThreads=10";
directives : content: loc,if in loc
- hi_java_servlet,default:""
example:
hi_java_servlet hi/jhello;
directives : content : http,srv,loc,if in loc ,if in srv
- hi_java_servlet_cache_expires,default:300s
example:
hi_java_servlet_cache_expires 300s;
directives : content : http,srv,loc,if in loc ,if in srv
- hi_java_servlet_cache_size,default:10
example:
hi_java_servlet_cache_size 10;
directives : content: http,srv,if in srv
- hi_java_version,default:8
example:
hi_java_version 8;
directives : content: loc,if in loc
- hi_php_script,default: ""
example:
location ~ \.php$ {
hi_php_script php;
}
or
location / {
hi_php_script php/index.php;
}
directives : content: loc,if in loc
- hi_javascript_lang,default:javascript
example:
hi_javascript_lang javascript;
directives : content: loc,if in loc
- hi_javascript_extension,default:js
example:
hi_javascript_extension js;
directives : content: loc,if in loc
- hi_javascript_content,default:""
example:
hi_javascript_content "hi_res.content='hello,world';hi_res.status=200;";
directives : content: loc,if in loc
- hi_javascript_script,default:""
example:
hi_javascript_script javascript/index.js;
or
hi_javascript_script javascript;
directives : content: http,srv,loc,if in loc ,if in srv
- hi_javascript_compiledscript_expires,default:300s
example:
hi_javascript_compiledscript_expires 5m;
特别说明
以上配置命令演示均使用相对路径。如果你按照配置启动后发现404错误,多半是你启动hi-nginx的方式使得相对路径无效。
这时,较差的建议是把配置改成绝对路径。较好的建议是只通过systemctl
启动,从而确保启动目录正确、从而相对路径有效。
修改配置后,一定要systemctl reload nginx
。
感谢网友热情地提出增加关于使用相对路径的特别说明
的建议。