Openresty + mginx-rtmp-module
/home/cascade/src/openresty-1.25.3.1>mkdir module ; cd module;
/home/cascade/src/openresty-1.25.3.1/module>wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
/home/cascade/src/openresty-1.25.3.1/module>cd ..
/home/cascade/src/openresty-1.25.3.1>./configure --prefix=$HOME/lua2 --with-http_ssl_module --add-module=/nginx-dependence/nginx-rtmp-module
/home/cascade/src/openresty-1.25.3.1/module>gmake -j 9
/home/cascade/src/openresty-1.25.3.1/module>gmake install
/home/cascade/src/openresty-1.25.3.1/module>
lua2
/home/cascade>com-tree $HOME/lua2
| | |____lua2
| | | |____bin
| | | | |____md2pod.pl
| | | | |____nginx-xml2pod
| | | | |____openresty
| | | | |____opm
| | | | |____resty
| | | | |____restydoc
| | | | |____restydoc-index
| | | |____COPYRIGHT
| | | |____luajit
| | | | |____bin
| | | | | |____luajit
| | | | | |____luajit-2.1.ROLLING
| | | | |____include
| | | | | |____luajit-2.1
| | | | | | |____lauxlib.h
| | | | | | |____luaconf.h
| | | | | | |____lua.h
| | | | | | |____lua.hpp
| | | | | | |____luajit.h
| | | | | | |____lualib.h
| | | | |____lib
| | | | | |____libluajit-5.1.a
| | | | | |____libluajit-5.1.so
| | | | | |____libluajit-5.1.so.2
| | | | | |____libluajit-5.1.so.2.1.ROLLING
| | | | | |____lua
| | | | | | |____5.1
| | | | | |____pkgconfig
| | | | | | |____luajit.pc
| | | | |____share
| | | | | |____lua
| | | | | | |____5.1
| | | | | |____luajit-2.1
| | | | | | |____jit
| | | | | | | |____bc.lua
| | | | | | | |____bcsave.lua
| | | | | | | |____dis_arm64be.lua
| | | | | | | |____dis_arm64.lua
| | | | | | | |____dis_arm.lua
| | | | | | | |____dis_mips64el.lua
| | | | | | | |____dis_mips64.lua
| | | | | | | |____dis_mips64r6el.lua
| | | | | | | |____dis_mips64r6.lua
| | | | | | | |____dis_mipsel.lua
| | | | | | | |____dis_mips.lua
| | | | | | | |____dis_ppc.lua
| | | | | | | |____dis_x64.lua
| | | | | | | |____dis_x86.lua
| | | | | | | |____dump.lua
| | | | | | | |____p.lua
| | | | | | | |____v.lua
| | | | | | | |____vmdef.lua
| | | | | | | |____zone.lua
| | | | | |____man
| | | | | | |____man1
| | | | | | | |____luajit.1
| | | |____lualib
| | | | |____cjson.so
| | | | |____librestysignal.so
| | | | |____ngx
| | | | | |____balancer.lua
| | | | | |____base64.lua
| | | | | |____errlog.lua
| | | | | |____ocsp.lua
| | | | | |____pipe.lua
| | | | | |____process.lua
| | | | | |____re.lua
| | | | | |____req.lua
| | | | | |____resp.lua
| | | | | |____semaphore.lua
| | | | | |____ssl
| | | | | | |____clienthello.lua
| | | | | |____ssl.lua
| | | | | | |____session.lua
| | | | |____rds
| | | | | |____parser.so
| | | | |____redis
| | | | | |____parser.so
| | | | |____resty
| | | | | |____aes.lua
| | | | | |____core
| | | | | | |____base64.lua
| | | | | | |____base.lua
| | | | | | |____coroutine.lua
| | | | | | |____ctx.lua
| | | | | | |____exit.lua
| | | | | | |____hash.lua
| | | | | |____core.lua
| | | | | | |____misc.lua
| | | | | | |____ndk.lua
| | | | | | |____param.lua
| | | | | | |____phase.lua
| | | | | | |____regex.lua
| | | | | | |____request.lua
| | | | | | |____response.lua
| | | | | | |____shdict.lua
| | | | | | |____socket.lua
| | | | | | |____time.lua
| | | | | | |____uri.lua
| | | | | | |____utils.lua
| | | | | | |____var.lua
| | | | | | |____worker.lua
| | | | | |____dns
| | | | | | |____resolver.lua
| | | | | |____limit
| | | | | | |____conn.lua
| | | | | | |____count.lua
| | | | | | |____req.lua
| | | | | | |____traffic.lua
| | | | | |____lock.lua
| | | | | |____lrucache
| | | | | |____lrucache.lua
| | | | | | |____pureffi.lua
| | | | | |____md5.lua
| | | | | |____memcached.lua
| | | | | |____mysql.lua
| | | | | |____random.lua
| | | | | |____redis.lua
| | | | | |____sha1.lua
| | | | | |____sha224.lua
| | | | | |____sha256.lua
| | | | | |____sha384.lua
| | | | | |____sha512.lua
| | | | | |____sha.lua
| | | | | |____shell.lua
| | | | | |____signal.lua
| | | | | |____string.lua
| | | | | |____upload.lua
| | | | | |____upstream
| | | | | | |____healthcheck.lua
| | | | | |____websocket
| | | | | | |____client.lua
| | | | | | |____protocol.lua
| | | | | | |____server.lua
| | | | |____tablepool.lua
| | | |____nginx
| | | | |____conf
| | | | | |____fastcgi.conf
| | | | | |____fastcgi.conf.default
| | | | | |____fastcgi_params
| | | | | |____fastcgi_params.default
| | | | | |____koi-utf
| | | | | |____koi-win
| | | | | |____mime.types
| | | | | |____mime.types.default
| | | | | |____nginx.conf
| | | | | |____nginx.conf.default
| | | | | |____scgi_params
| | | | | |____scgi_params.default
| | | | | |____uwsgi_params
| | | | | |____uwsgi_params.default
| | | | | |____win-utf
| | | | |____html
| | | | | |____50x.html
| | | | | |____index.html
| | | | |____logs
| | | | |____sbin
| | | | | |____nginx
| | | |____pod
| | | | |____array-var-nginx-module-0.06
| | | | | |____array-var-nginx-module-0.06.pod
| | | | |____drizzle-nginx-module-0.1.12
| | | | | |____drizzle-nginx-module-0.1.12.pod
| | | | |____echo-nginx-module-0.63
| | | | | |____echo-nginx-module-0.63.pod
| | | | |____encrypted-session-nginx-module-0.09
| | | | | |____encrypted-session-nginx-module-0.09.pod
| | | | |____form-input-nginx-module-0.12
| | | | | |____form-input-nginx-module-0.12.pod
| | | | |____headers-more-nginx-module-0.37
| | | | | |____headers-more-nginx-module-0.37.pod
| | | | |____iconv-nginx-module-0.14
| | | | | |____iconv-nginx-module-0.14.pod
| | | | |____lua-5.1.5
| | | | | |____lua-5.1.5.pod
| | | | |____lua-cjson-2.1.0.13
| | | | | |____lua-cjson-2.1.0.13.pod
| | | | |____luajit-2.1
| | | | |____luajit-2.1-20231117
| | | | | |____luajit-2.1-20231117.pod
| | | | | |____changes.pod
| | | | | |____contact.pod
| | | | | |____ext_c_api.pod
| | | | | |____extensions.pod
| | | | | |____ext_ffi_api.pod
| | | | | |____ext_ffi.pod
| | | | | |____ext_ffi_semantics.pod
| | | | | |____ext_ffi_tutorial.pod
| | | | | |____ext_jit.pod
| | | | | |____ext_profiler.pod
| | | | | |____faq.pod
| | | | | |____install.pod
| | | | | |____luajit-2.1.pod
| | | | | |____running.pod
| | | | | |____status.pod
| | | | |____lua-rds-parser-0.06
| | | | |____lua-redis-parser-0.13
| | | | | |____lua-redis-parser-0.13.pod
| | | | |____lua-resty-core-0.1.28
| | | | | |____lua-resty-core-0.1.28.pod
| | | | | |____ngx.balancer.pod
| | | | | |____ngx.base64.pod
| | | | | |____ngx.errlog.pod
| | | | | |____ngx.ocsp.pod
| | | | | |____ngx.pipe.pod
| | | | | |____ngx.process.pod
| | | | | |____ngx.re.pod
| | | | | |____ngx.req.pod
| | | | | |____ngx.resp.pod
| | | | | |____ngx.semaphore.pod
| | | | | |____ngx.ssl.clienthello.pod
| | | | | |____ngx.ssl.pod
| | | | | |____ngx.ssl.session.pod
| | | | | |____resty.core.time.pod
| | | | |____lua-resty-dns-0.23
| | | | | |____lua-resty-dns-0.23.pod
| | | | |____lua-resty-limit-traffic-0.09
| | | | | |____lua-resty-limit-traffic-0.09.pod
| | | | | |____resty.limit.conn.pod
| | | | | |____resty.limit.count.pod
| | | | | |____resty.limit.req.pod
| | | | | |____resty.limit.traffic.pod
| | | | |____lua-resty-lock-0.09
| | | | | |____lua-resty-lock-0.09.pod
| | | | |____lua-resty-lrucache-0.13
| | | | | |____lua-resty-lrucache-0.13.pod
| | | | |____lua-resty-memcached-0.17
| | | | | |____lua-resty-memcached-0.17.pod
| | | | |____lua-resty-mysql-0.27
| | | | | |____lua-resty-mysql-0.27.pod
| | | | |____lua-resty-redis-0.30
| | | | | |____lua-resty-redis-0.30.pod
| | | | |____lua-resty-shell-0.03
| | | | | |____lua-resty-shell-0.03.pod
| | | | |____lua-resty-signal-0.03
| | | | | |____lua-resty-signal-0.03.pod
| | | | |____lua-resty-string-0.15
| | | | | |____lua-resty-string-0.15.pod
| | | | |____lua-resty-upload-0.11
| | | | | |____lua-resty-upload-0.11.pod
| | | | |____lua-resty-upstream-healthcheck-0.08
| | | | | |____lua-resty-upstream-healthcheck-0.08.pod
| | | | |____lua-resty-websocket-0.11
| | | | | |____lua-resty-websocket-0.11.pod
| | | | |____lua-tablepool-0.03
| | | | | |____lua-tablepool-0.03.pod
| | | | |____memc-nginx-module-0.20
| | | | | |____memc-nginx-module-0.20.pod
| | | | |____nginx
| | | | | |____accept_failed.pod
| | | | | |____beginners_guide.pod
| | | | | |____chunked_encoding_from_backend.pod
| | | | | |____configure.pod
| | | | | |____configuring_https_servers.pod
| | | | | |____contributing_changes.pod
| | | | | |____control.pod
| | | | | |____converting_rewrite_rules.pod
| | | | | |____daemon_master_process_off.pod
| | | | | |____debugging_log.pod
| | | | | |____development_guide.pod
| | | | | |____events.pod
| | | | | |____example.pod
| | | | | |____faq.pod
| | | | | |____freebsd_tuning.pod
| | | | | |____hash.pod
| | | | | |____howto_build_on_win32.pod
| | | | | |____install.pod
| | | | | |____license_copyright.pod
| | | | | |____load_balancing.pod
| | | | | |____nginx_dtrace_pid_provider.pod
| | | | | |____nginx.pod
| | | | | |____ngx_core_module.pod
| | | | | |____ngx_google_perftools_module.pod
| | | | | |____ngx_http_access_module.pod
| | | | | |____ngx_http_addition_module.pod
| | | | | |____ngx_http_api_module_head.pod
| | | | | |____ngx_http_auth_basic_module.pod
| | | | | |____ngx_http_auth_jwt_module.pod
| | | | | |____ngx_http_auth_request_module.pod
| | | | | |____ngx_http_autoindex_module.pod
| | | | | |____ngx_http_browser_module.pod
| | | | | |____ngx_http_charset_module.pod
| | | | | |____ngx_http_core_module.pod
| | | | | |____ngx_http_dav_module.pod
| | | | | |____ngx_http_empty_gif_module.pod
| | | | | |____ngx_http_f4f_module.pod
| | | | | |____ngx_http_fastcgi_module.pod
| | | | | |____ngx_http_flv_module.pod
| | | | | |____ngx_http_geoip_module.pod
| | | | | |____ngx_http_geo_module.pod
| | | | | |____ngx_http_grpc_module.pod
| | | | | |____ngx_http_gunzip_module.pod
| | | | | |____ngx_http_gzip_module.pod
| | | | | |____ngx_http_gzip_static_module.pod
| | | | | |____ngx_http_headers_module.pod
| | | | | |____ngx_http_hls_module.pod
| | | | | |____ngx_http_image_filter_module.pod
| | | | | |____ngx_http_index_module.pod
| | | | | |____ngx_http_internal_redirect_module.pod
| | | | | |____ngx_http_js_module.pod
| | | | | |____ngx_http_keyval_module.pod
| | | | | |____ngx_http_limit_conn_module.pod
| | | | | |____ngx_http_limit_req_module.pod
| | | | | |____ngx_http_log_module.pod
| | | | | |____ngx_http_map_module.pod
| | | | | |____ngx_http_memcached_module.pod
| | | | | |____ngx_http_mirror_module.pod
| | | | | |____ngx_http_mp4_module.pod
| | | | | |____ngx_http_perl_module.pod
| | | | | |____ngx_http_proxy_module.pod
| | | | | |____ngx_http_proxy_protocol_vendor_module.pod
| | | | | |____ngx_http_random_index_module.pod
| | | | | |____ngx_http_realip_module.pod
| | | | | |____ngx_http_referer_module.pod
| | | | | |____ngx_http_rewrite_module.pod
| | | | | |____ngx_http_scgi_module.pod
| | | | | |____ngx_http_secure_link_module.pod
| | | | | |____ngx_http_session_log_module.pod
| | | | | |____ngx_http_slice_module.pod
| | | | | |____ngx_http_spdy_module.pod
| | | | | |____ngx_http_split_clients_module.pod
| | | | | |____ngx_http_ssi_module.pod
| | | | | |____ngx_http_ssl_module.pod
| | | | | |____ngx_http_status_module.pod
| | | | | |____ngx_http_stub_status_module.pod
| | | | | |____ngx_http_sub_module.pod
| | | | | |____ngx_http_upstream_conf_module.pod
| | | | | |____ngx_http_upstream_hc_module.pod
| | | | | |____ngx_http_upstream_module.pod
| | | | | |____ngx_http_userid_module.pod
| | | | | |____ngx_http_uwsgi_module.pod
| | | | | |____ngx_http_v2_module.pod
| | | | | |____ngx_http_v3_module.pod
| | | | | |____ngx_http_xslt_module.pod
| | | | | |____ngx_mail_auth_http_module.pod
| | | | | |____ngx_mail_core_module.pod
| | | | | |____ngx_mail_imap_module.pod
| | | | | |____ngx_mail_pop3_module.pod
| | | | | |____ngx_mail_proxy_module.pod
| | | | | |____ngx_mail_realip_module.pod
| | | | | |____ngx_mail_smtp_module.pod
| | | | | |____ngx_mail_ssl_module.pod
| | | | | |____ngx_mgmt_module.pod
| | | | | |____ngx_otel_module.pod
| | | | | |____ngx_stream_access_module.pod
| | | | | |____ngx_stream_core_module.pod
| | | | | |____ngx_stream_geoip_module.pod
| | | | | |____ngx_stream_geo_module.pod
| | | | | |____ngx_stream_js_module.pod
| | | | | |____ngx_stream_keyval_module.pod
| | | | | |____ngx_stream_limit_conn_module.pod
| | | | | |____ngx_stream_log_module.pod
| | | | | |____ngx_stream_map_module.pod
| | | | | |____ngx_stream_mqtt_filter_module.pod
| | | | | |____ngx_stream_mqtt_preread_module.pod
| | | | | |____ngx_stream_proxy_module.pod
| | | | | |____ngx_stream_proxy_protocol_vendor_module.pod
| | | | | |____ngx_stream_realip_module.pod
| | | | | |____ngx_stream_return_module.pod
| | | | | |____ngx_stream_set_module.pod
| | | | | |____ngx_stream_split_clients_module.pod
| | | | | |____ngx_stream_ssl_module.pod
| | | | | |____ngx_stream_ssl_preread_module.pod
| | | | | |____ngx_stream_upstream_hc_module.pod
| | | | | |____ngx_stream_upstream_module.pod
| | | | | |____ngx_stream_zone_sync_module.pod
| | | | | |____quic.pod
| | | | | |____request_processing.pod
| | | | | |____server_names.pod
| | | | | |____stream_processing.pod
| | | | | |____switches.pod
| | | | | |____syntax.pod
| | | | | |____sys_errlist.pod
| | | | | |____syslog.pod
| | | | | |____variables_in_config.pod
| | | | | |____websocket.pod
| | | | | |____welcome_nginx_facebook.pod
| | | | | |____windows.pod
| | | | |____ngx_coolkit-0.2
| | | | |____ngx_devel_kit-0.3.3
| | | | | |____ngx_devel_kit-0.3.3.pod
| | | | | |____readme_auto_lib.pod
| | | | |____ngx_lua-0.10.26
| | | | | |____ngx_lua-0.10.26.pod
| | | | |____ngx_lua_upstream-0.07
| | | | | |____ngx_lua_upstream-0.07.pod
| | | | |____ngx_postgres-1.0
| | | | | |____ngx_postgres-1.0.pod
| | | | | |____todo.pod
| | | | |____ngx_stream_lua-0.0.14
| | | | | |____dev_notes.pod
| | | | | |____ngx_stream_lua-0.0.14.pod
| | | | |____opm-0.0.8
| | | | | |____opm-0.0.8.pod
| | | | | |____web.docs.md.docs.pod
| | | | |____rds-csv-nginx-module-0.09
| | | | | |____rds-csv-nginx-module-0.09.pod
| | | | |____rds-json-nginx-module-0.16
| | | | | |____rds-json-nginx-module-0.16.pod
| | | | |____redis2-nginx-module-0.15
| | | | | |____redis2-nginx-module-0.15.pod
| | | | |____redis-nginx-module-0.3.9
| | | | |____resty-cli-0.30
| | | | | |____resty-cli-0.30.pod
| | | | |____set-misc-nginx-module-0.33
| | | | | |____set-misc-nginx-module-0.33.pod
| | | | |____srcache-nginx-module-0.33
| | | | | |____srcache-nginx-module-0.33.pod
| | | | |____xss-nginx-module-0.06
| | | | | |____xss-nginx-module-0.06.pod
| | | |____resty.index
| | | |____site
| | | | |____lualib
| | | | |____manifest
| | | | |____pod
nginx.conf
server {
listen 5678;
server_name localhost;
CGI
location /api/live/existed {
default_type text/html;
content_by_lua_file /bin/api_file_existed.lua;
}
location /api/test/success {
content_by_lua_block {
ngx.header.content_type = 'text/html; charset=utf-8'
local pipe = io.popen("/bin/com-success")
local result = pipe:read("*a")
pipe:close()
ngx.say(result)
}
}
location /api/test/error {
content_by_lua_block {
ngx.header.content_type = 'text/html; charset=utf-8'
local pipe = io.popen("/bin/com-error")
local result = pipe:read("*a")
pipe:close()
ngx.say(result)
}
}
exit code
if [ $? -eq 0 ]; then
echo "Command executed successfully."
fi
if [ $? -ne 0 ]; then
echo "Command failed with exit code $?"
fi
com-success
RESULT=0
if [ $RESULT -eq 0 ]; then
TOKEN=21232f297a57a5a743894a0e4a801fc3
echo '{"code":0,"msg":"success","data":{"token":"'$TOKEN'"}}'
fi
com-error
RESULT=1
if [ $RESULT -ne 0 ]; then
TOKEN=
echo '{"code":1,"msg":"error","data":{"token":"'$TOKEN'"}}'
fi
/home/cascade/lua2/nginx>sbin/nginx -s reload
/home/cascade/lua2/nginx>
/home/cascade/lua2/nginx>netstat -an | grep 5678
tcp 0 0 0.0.0.0:5678 0.0.0.0:* LISTEN
Check URI exists
-- ---------------------------------------------------------------------------
-- PLEASE DO NOT EDIT THIS FILE
-- ---------------------------------------------------------------------------
ngx.header.content_type = 'text/html; charset=utf-8'
ngx.header["Access-Control-Allow-Origin"] = "*"
ngx.header["Access-Control-Allow-Headers"] = "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range, userid, agent, brandid, language, token"
if ngx.var.request_method == "OPTIONS" then
ngx.header["Access-Control-Max-Age"] = "1728000"
ngx.header["Access-Control-Allow-Methods"] = "GET, POST, OPTIONS, PUT, DELETE"
ngx.header["Content-Length"] ="0"
ngx.header["Content-Type"] = "text/plain, charset=utf-8"
end
-- ---------------------------------------------------------------------------
local args = ngx.req.get_uri_args()
local params = {}
for k,v in pairs(args) do
params[k] = v
end
-- ---------------------------------------------------------------------------
local uri = 'uri'
if params[uri] == nil or params[uri] == "" then
ngx.say("Parameter [", index, "] IS NULL")
ngx.say("<br>")
return
else
ngx.log(ngx.DEBUG, uri, "\t[", params[uri], "]")
end
-- ---------------------------------------------------------------------------
local pipe = io.popen("/bin/com-file-existed " .. params[uri] .. "")
local result = pipe:read("*a")
pipe:close()
ngx.say(result)
-- ---------------------------------------------------------------------------
########################################################################
# PLEASE DO NOT EDIT THIS FILE
########################################################################
FILE=$1
REMOTE=/root/lua/nginx/html
REMOTE_FILE=$REMOTE''$FILE''
########################################################################
RESULT=0
ls -l $REMOTE_FILE > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo '{"code":0,"msg":"success","data":{"path":"'$FILE'"}}'
else
echo '{"code":1,"msg":"error","data":{"path":"'$FILE'"}}'
fi