Working with cookies in a Nginx module

Imagine you run a PPC advertising campaign and you want to find out how many visitors coming from a search engine result in sales. We will create an Nginx module and use cookies for this purpose. Whenever a visitor clicks on your ad, a landing page is requested with a tracking argument in it. The […]

How to return a simple page

Let’s see what we need to do in order to return a simple page to a client using Nginx module. We need to generate a header and a body of the response. To send a response header we use function ngx_http_send_header: #include <ngx_http.h> ngx_int_t ngx_http_send_header(ngx_http_request_t *r); The only argument r is the request for which […]

HTTP request processing phases in Nginx

Nginx processes HTTP requests in multiple phases. In each of the phases there might be 0 or more handlers called. In the Nginx source code phases have specific constants associated with them. Here is a list of all phases: NGX_HTTP_SERVER_REWRITE_PHASE — the phase of request URI transformation on the virtual server level; NGX_HTTP_FIND_CONFIG_PHASE — the […]

  • 1
  • 2