### Nginx Module Integration with Lua Source: https://context7.com/agile6v/awesome-nginx/llms.txt Example of configuring and building Nginx with a third-party module, specifically lua-nginx-module. It covers downloading Nginx, cloning the module, configuring the build with the module, and installing it. Also includes a basic Nginx configuration for using Lua. ```bash # Example: Building nginx with lua-nginx-module # Download nginx source wget http://nginx.org/download/nginx-1.25.0.tar.gz tar -xzvf nginx-1.25.0.tar.gz cd nginx-1.25.0 # Clone the module git clone https://github.com/openresty/lua-nginx-module.git # Configure nginx with the module ./configure --add-module=/path/to/lua-nginx-module make sudo make install # Use in nginx.conf: # location /lua { # content_by_lua_block { # ngx.say("Hello from Lua!") # } # } ``` -------------------------------- ### Travis CI Configuration for C Projects Source: https://context7.com/agile6v/awesome-nginx/llms.txt Basic Travis CI configuration for a C language project. It automatically detects the language and sets up a default build and test environment using gcc. This is a minimal example for automated CI/CD pipelines. ```yaml language: "c" ``` ```bash # The Travis CI pipeline will: # 1. Detect the language as C # 2. Use default C compiler (gcc) # 3. Execute: ./configure && make && make test # 4. Report build status # Example .travis.yml usage in your repository: # - Push commits to trigger automated builds # - Travis CI will compile and test automatically # - Build status badge shows pass/fail state ``` -------------------------------- ### Create Custom Nginx C Module Source: https://context7.com/agile6v/awesome-nginx/llms.txt Example of creating a basic 'Hello World' Nginx HTTP module in C. This involves defining module commands, a request handler, and the module structure. It requires Nginx development headers and can be compiled using the standard Nginx build process. ```c // ngx_http_hello_module.c #include #include #include static char *ngx_http_hello(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static ngx_int_t ngx_http_hello_handler(ngx_http_request_t *r); static ngx_command_t ngx_http_hello_commands[] = { { ngx_string("hello"), NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS, ngx_http_hello, 0, 0, NULL }, ngx_null_command }; static ngx_http_module_t ngx_http_hello_module_ctx = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; ngx_module_t ngx_http_hello_module = { NGX_MODULE_V1, &ngx_http_hello_module_ctx, ngx_http_hello_commands, NGX_HTTP_MODULE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NGX_MODULE_V1_PADDING }; static ngx_int_t ngx_http_hello_handler(ngx_http_request_t *r) { ngx_buf_t *b; ngx_chain_t out; u_char msg[] = "Hello from custom nginx module!"; r->headers_out.content_type.len = sizeof("text/plain") - 1; r->headers_out.content_type.data = (u_char *) "text/plain"; r->headers_out.status = NGX_HTTP_OK; r->headers_out.content_length_n = sizeof(msg) - 1; b = ngx_create_temp_buf(r->pool, sizeof(msg) - 1); if (b == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } ngx_memcpy(b->pos, msg, sizeof(msg) - 1); b->last = b->pos + sizeof(msg) - 1; b->last_buf = 1; out.buf = b; out.next = NULL; ngx_http_send_header(r); return ngx_http_output_filter(r, &out); } static char *ngx_http_hello(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_core_loc_conf_t *clcf; clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); clcf->handler = ngx_http_hello_handler; return NGX_CONF_OK; } ``` ```bash // Build and use: // ./configure --add-module=/path/to/ngx_http_hello_module // make && make install // // nginx.conf: // location /hello { // hello; // } ``` -------------------------------- ### OpenResty Lua Redis Client Example Source: https://context7.com/agile6v/awesome-nginx/llms.txt Demonstrates using the lua-resty-redis module within an OpenResty Nginx environment. It shows how to connect to a Redis server, set a key-value pair, retrieve the value, and manage the connection pool. Requires Nginx with OpenResty and a running Redis instance. ```lua -- nginx.conf location block: -- location /redis { -- content_by_lua_file /path/to/redis_example.lua; -- } local redis = require "resty.redis" local red = redis:new() red:set_timeout(1000) -- 1 second -- Connect to Redis local ok, err = red:connect("127.0.0.1", 6379) if not ok then ngx.say("Failed to connect: ", err) return end -- Set a value ok, err = red:set("awesome_nginx", "true") if not ok then ngx.say("Failed to set: ", err) return end -- Get the value local res, err = red:get("awesome_nginx") if not res then ngx.say("Failed to get: ", err) return end ngx.say("Value: ", res) -- Put connection into connection pool local ok, err = red:set_keepalive(10000, 100) if not ok then ngx.say("Failed to set keepalive: ", err) return end ``` -------------------------------- ### Hello World Test Program in C Source: https://context7.com/agile6v/awesome-nginx/llms.txt A minimal C program designed for continuous integration testing. It outputs a simple greeting message to verify the build and test pipeline. No external dependencies are required. ```c #include int main(int argc, char** argv) { printf("Hello travis CI!\n"); return 0; } ``` -------------------------------- ### Placeholder Configure Script for Nginx Builds Source: https://context7.com/agile6v/awesome-nginx/llms.txt An executable placeholder script for build configuration. This script is currently empty but can be extended with autoconf or custom logic to manage Nginx build configurations, facilitating custom module integration. ```bash #!/bin/bash # The configure script is currently empty but executable # It can be extended to support custom build configuration # Usage example: ./configure make make test # Expected behavior: # - configure: Exits successfully (no configuration needed) # - make: Compiles hello.c to hello executable # - make test: Runs ./hello and displays "Hello travis CI!" ``` -------------------------------- ### Makefile for Nginx C Project Build Automation Source: https://context7.com/agile6v/awesome-nginx/llms.txt A Makefile providing build automation for a C project, including targets for compilation, testing, and cleanup. It simplifies the build process for Nginx-related C programs. ```makefile # Build the hello executable all: hello # Run the test program test: ./hello # Clean build artifacts clean: rm -f hello *.o ``` ```bash # Compile the program make all # Run tests make test # Expected output: # ./hello # Hello travis CI! # Clean up build artifacts make clean ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.