Skip to content

Commit

Permalink
Prettify take #2.
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrSikora committed Sep 15, 2010
1 parent 1784ba8 commit 9ad608b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
@@ -1,12 +1,14 @@
About
=====

`ngx_postgres` is an upstream module that allows `nginx` to communicate directly with `PostgreSQL` database.

Response is generated in `rds` format, so it's compatible with `ngx_rds_json` and `ngx_drizzle` modules.


Status
======

This module is production-ready and it's compatible with following nginx releases:

- 0.7.x (tested with 0.7.60 to 0.7.67),
Expand All @@ -15,8 +17,10 @@ This module is production-ready and it's compatible with following nginx release

Configuration directives
========================

postgres_server
---------------

**syntax**: `postgres_server ip[:port] dbname=dbname user=user password=pass`
**default**: `none`
**context**: `upstream`
Expand All @@ -26,6 +30,7 @@ Set details about the database server.

postgres_keepalive
------------------

**syntax**: `postgres_keepalive off | max=count [mode=single|multi] [overflow=ignore|reject]`
**default**: `max=10 mode=single overflow=ignore`
**context**: `upstream`
Expand All @@ -39,6 +44,7 @@ Configure keepalive parameters:

postgres_pass
-------------

**syntax**: `postgres_pass upstream`
**default**: `none`
**context**: `location`
Expand All @@ -48,6 +54,7 @@ Set name of an upstream block that will be used for the database connections (it

postgres_query
--------------

**syntax**: `postgres_query [methods] query`
**default**: `none`
**context**: `http`, `server`, `location`
Expand All @@ -59,6 +66,7 @@ This directive can be used more than once within same context.

postgres_rewrite
----------------

**syntax**: `postgres_rewrite [methods] condition status_code`
**default**: `none`
**context**: `http`, `server`, `location`
Expand All @@ -77,6 +85,7 @@ This directive can be used more than once within same context.

postgres_output
---------------

**syntax**: `postgres_output none|value|row|rds [row] [column]`
**default**: `rds`
**context**: `http`, `server`, `location`
Expand All @@ -93,6 +102,7 @@ Row and column numbers start at 0. Column name can be used instead of column num

postgres_set
------------

**syntax**: `postgres_set $variable row column [optional|required]`
**default**: `none`
**context**: `http`, `server`, `location`
Expand All @@ -106,6 +116,7 @@ This directive can be used more than once within same context.

postgres_escape
---------------

**syntax**: `postgres_escape $escaped $unescaped`
**default**: `none`
**context**: `http`, `server`, `location`
Expand All @@ -115,6 +126,7 @@ Escape and quote `$unescaped` variable. Result is stored in `$escaped` variable

postgres_connect_timeout
------------------------

**syntax**: `postgres_connect_timeout timeout`
**default**: `10s`
**context**: `http`, `server`, `location`
Expand All @@ -124,6 +136,7 @@ Set timeout for connecting to the database.

postgres_result_timeout
-----------------------

**syntax**: `postgres_result_timeout timeout`
**default**: `30s`
**context**: `http`, `server`, `location`
Expand All @@ -133,30 +146,37 @@ Set timeout for receiving result from the database.

Configuration variables
=======================

$postgres_columns
-----------------

Number of columns in received result-set.


$postgres_rows
--------------

Number of rows in received result-set.


$postgres_affected
------------------

Number of rows affected by `INSERT`, `UPDATE`, `DELETE`, `MOVE`, `FETCH` or `COPY` SQL query.


$postgres_query
---------------

SQL query, as seen by `PostgreSQL` database.


Sample configurations
=====================

Sample configuration #1
-----------------------

Return content of table `cats` (in `rds` format).

http {
Expand All @@ -176,6 +196,7 @@ Return content of table `cats` (in `rds` format).

Sample configuration #2
-----------------------

Return only those rows from table `sites` that match `host` filter which is evaluated for each request based on its `$http_host` variable.

http {
Expand All @@ -195,6 +216,7 @@ Return only those rows from table `sites` that match `host` filter which is eval

Sample configuration #3
-----------------------

Pass request to the backend selected from the database (traffic router).

http {
Expand Down Expand Up @@ -224,6 +246,7 @@ Required modules (other than `ngx_postgres`):

Sample configuration #4
-----------------------

Restrict access to local files by authenticating against `PostgreSQL` database.

http {
Expand Down Expand Up @@ -259,6 +282,7 @@ Required modules (other than `ngx_postgres`):

Sample configuration #5
-----------------------

Simple RESTful webservice returning JSON responses with appropriate HTTP status codes.

http {
Expand Down Expand Up @@ -307,6 +331,7 @@ Required modules (other than `ngx_postgres`):

Testing
=======

`ngx_postgres` comes with complete test suite based on [Test::Nginx](http://github.com/agentzh/test-nginx).

You can test core functionality using:
Expand All @@ -328,6 +353,7 @@ using:

License
=======

Copyright (c) 2010, FRiCKLE Piotr Sikora <info@frickle.com>
Copyright (c) 2009-2010, Xiaozhe Wang <chaoslawful@gmail.com>
Copyright (c) 2009-2010, Yichun Zhang <agentzh@gmail.com>
Expand Down Expand Up @@ -360,6 +386,7 @@ This software includes also parts of the code from `nginx` (copyrighted by **Igo

See also
========

- [ngx_rds_json](http://github.com/agentzh/rds-json-nginx-module),
- [ngx_drizzle](http://github.com/chaoslawful/drizzle-nginx-module),
- [ngx_lua](http://github.com/chaoslawful/lua-nginx-module),
Expand Down

0 comments on commit 9ad608b

Please sign in to comment.