{"id":22568159,"url":"https://github.com/rekgrpth/ngx_pg_module","last_synced_at":"2026-02-13T15:06:32.497Z","repository":{"id":104667478,"uuid":"444657656","full_name":"RekGRpth/ngx_pg_module","owner":"RekGRpth","description":"Nginx raw PostgreSQL connection, it uses ragel-based PostgreSQL connection parser with zero-alloc and zero-copy","archived":false,"fork":false,"pushed_at":"2026-01-01T19:10:32.000Z","size":1868,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-07T03:11:04.178Z","etag":null,"topics":["connection","nginx","postgres","raw"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RekGRpth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-05T04:01:20.000Z","updated_at":"2026-01-01T19:10:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"3cd993b8-eacf-436a-bca5-0474ece7efc9","html_url":"https://github.com/RekGRpth/ngx_pg_module","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RekGRpth/ngx_pg_module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RekGRpth%2Fngx_pg_module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RekGRpth%2Fngx_pg_module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RekGRpth%2Fngx_pg_module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RekGRpth%2Fngx_pg_module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RekGRpth","download_url":"https://codeload.github.com/RekGRpth/ngx_pg_module/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RekGRpth%2Fngx_pg_module/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29411138,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["connection","nginx","postgres","raw"],"created_at":"2024-12-08T00:11:46.533Z","updated_at":"2026-02-13T15:06:32.476Z","avatar_url":"https://github.com/RekGRpth.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"deprecated, use https://github.com/RekGRpth/ngx_pq_module instead\n\n# Nginx raw PostgreSQL connection\nit uses ragel-based PostgreSQL connection parser with zero-alloc and zero-copy\n\n# Directives\n\npg_execute\n-------------\n* Syntax: **pg_execute** *$query* [ *$arg* ] [ output=*csv* | output=*plain* | output=*value* | output=*$variable* ]\n* Default: --\n* Context: location, if in location, upstream\n\nExecutes query(queries) (nginx variables allowed) sql(s) (named only nginx variables allowed as identifier only), optional argument(s) (nginx variables allowed) and output type (no nginx variables allowed):\n```nginx\nlocation =/postgres {\n    pg_pass postgres; # upstream is postgres\n    pg_execute $query str $arg output=plain; # execute extended query wich name is taken from $query variable with two arguments: first query argument is str and second query argument is taken from $arg variable and plain output type\n}\n```\npg_function\n-------------\n* Syntax: **pg_function** *$oid* [ *$arg* | *$arg*::*$oid* ] [ output=*value* ]\n* Default: --\n* Context: location, if in location, upstream\n\nSets function(s) oid (nginx variables allowed), optional argument(s) (nginx variables allowed) and it(s) oid(s) (nginx variables allowed) and output type (no nginx variables allowed):\n```nginx\nupstream postgres {\n    pg_option user=user database=database application_name=application_name; # set user, database and application_name\n    pg_query \"select p.oid from pg_catalog.pg_proc as p inner join pg_catalog.pg_namespace as n on n.oid = p.pronamespace where proname = $1 and nspname = $2\" now pg_catalog output=$now_oid; # extended query with two string arguments to variable\n    server postgres:5432; # host is postgres and port is 5432\n}\nlocation =/now {\n    pg_function $now_oid output=value; # call function by its oid\n    pg_pass postgres; # upstream is postgres\n}\n```\npg_log\n-------------\n* Syntax: **pg_log** *file* [ *level* ]\n* Default: error_log logs/error.log error;\n* Context: upstream\n\nSets logging (used when keepalive):\n```nginx\nupstream postgres {\n    pg_log /var/log/nginx/pg.err info; # set log level\n}\n```\npg_option\n-------------\n* Syntax: **pg_option** *name*=*value*\n* Default: --\n* Context: location, if in location, upstream\n\nSets connection option(s) (no nginx variables allowed), can be several:\n```nginx\nupstream postgres {\n    pg_option user=user database=database application_name=application_name; # set user, database and application_name\n    server postgres:5432; # host is postgres and port is 5432\n}\n# or\nupstream postgres {\n    pg_option user=user database=database application_name=application_name; # set user, database and application_name\n    server unix:///run/postgresql/.s.PGSQL.5432; # unix socket connetion\n}\n# or\nlocation =/postgres {\n    pg_option user=user database=database application_name=application_name; # set user, database and application_name\n    pg_pass postgres:5432; # host is postgres and port is 5432\n}\n# or\nlocation =/postgres {\n    pg_option user=user database=database application_name=application_name; # set user, database and application_name\n    pg_pass unix:///run/postgresql/.s.PGSQL.5432; # unix socket connetion\n}\n```\nIn upstream also may use nginx keepalive module:\n```nginx\nupstream postgres {\n    keepalive 8;\n    pg_option user=user database=database application_name=application_name; # set user, database and application_name\n    server postgres:5432; # host is postgres and port is 5432\n}\n# or\nupstream postgres {\n    keepalive 8;\n    pg_option user=user database=database application_name=application_name; # set user, database and application_name\n    server unix:///run/postgresql/.s.PGSQL.5432; # unix socket connetion\n}\n```\npg_prepare\n-------------\n* Syntax: **pg_prepare** *$query* *sql* [ *$oid* ]\n* Default: --\n* Context: location, if in location, upstream\n\nPrepare query(queries) (nginx variables allowed) sql(s) (named only nginx variables allowed as identifier only), optional argument(s)'s oid(s) (nginx variables allowed):\n```nginx\nlocation =/postgres {\n    pg_pass postgres; # upstream is postgres\n    pg_prepare $query \"SELECT $1, $2::text\" 25 \"\"; # parser query wich name is taken from $query variable and two arguments: first query argument oid is 25 (TEXTOID) and second query argument is auto oid\n}\n# or\nupstream postgres {\n    pg_option user=user database=database application_name=application_name; # set user, database and application_name\n    pg_prepare $query \"SELECT $1, $2::text\" 25 \"\"; # parser query wich name is taken from $query variable and two arguments: first query argument oid is 25 (TEXTOID) and second query argument is auto oid\n    server postgres:5432; # host is postgres and port is 5432\n}\n```\npg_pass\n-------------\n* Syntax: **pg_pass** *host*:*port* | unix://*socket* | *$upstream*\n* Default: --\n* Context: location, if in location\n\nSets host (no nginx variables allowed) and port (no nginx variables allowed) or unix socket (no nginx variables allowed) or upstream (nginx variables allowed):\n```nginx\nlocation =/postgres {\n    pg_pass postgres:5432; # host is postgres and port is 5432\n}\n# or\nlocation =/postgres {\n    pg_pass unix:///run/postgresql/.s.PGSQL.5432; # unix socket connetion\n}\n# or\nlocation =/postgres {\n    pg_pass postgres; # upstream is postgres\n}\n# or\nlocation =/postgres {\n    pg_pass $postgres; # upstream is taken from $postgres variable\n}\n```\npg_query\n-------------\n* Syntax: **pg_query** *sql* [ *$arg* | *$arg*::*$oid* ] [ output=*csv* | output=*plain* | output=*value* | output=*$variable* ]\n* Default: --\n* Context: location, if in location, upstream\n\nSets query(queries) sql(s) (named only nginx variables allowed as identifier only), optional argument(s) (nginx variables allowed) and it(s) oid(s) (nginx variables allowed) and output type (no nginx variables allowed):\n```nginx\nlocation =/postgres {\n    pg_pass postgres; # upstream is postgres\n    pg_query \"SELECT now()\" output=csv; # simple query and csv output type\n}\n# or\nlocation =/postgres {\n    pg_pass postgres; # upstream is postgres\n    pg_query \"listen $channel\"; # listen channel from variable $channel\n}\n# or\nlocation =/postgres {\n    pg_pass postgres; # upstream is postgres\n    pg_query \"SELECT 1/0\"; # simple query with error\n}\n# or\nlocation =/postgres {\n    pg_pass postgres; # upstream is postgres\n    pg_query \"SELECT $1, $2::text\" str::25 $arg output=plain; # extended query with two arguments: first query argument is str and its oid is 25 (TEXTOID) and second query argument is taken from $arg variable and auto oid and plain output type\n}\n```\n# Embedded Variables\n$pg_error_\n-------------\n* Syntax: $pg_error_*name*\n\nError *name* from connection:\n```nginx\nadd_header error_column $pg_error_column always;\nadd_header error_constraint $pg_error_constraint always;\nadd_header error_context $pg_error_context always;\nadd_header error_datatype $pg_error_datatype always;\nadd_header error_detail $pg_error_detail always;\nadd_header error_file $pg_error_file always;\nadd_header error_function $pg_error_function always;\nadd_header error_hint $pg_error_hint always;\nadd_header error_internal $pg_error_internal always;\nadd_header error_line $pg_error_line always;\nadd_header error_nonlocalized $pg_error_nonlocalized always;\nadd_header error_primary $pg_error_primary always;\nadd_header error_query $pg_error_query always;\nadd_header error_schema $pg_error_schema always;\nadd_header error_severity $pg_error_severity always;\nadd_header error_sqlstate $pg_error_sqlstate always;\nadd_header error_statement $pg_error_statement always;\nadd_header error_table $pg_error_table always;\n```\n$pg_option_\n-------------\n* Syntax: $pg_option_*name*\n\nOption *name* from connection:\n```nginx\nadd_header option_application_name $pg_option_application_name;\nadd_header option_client_encoding $pg_option_client_encoding;\nadd_header option_datestyle $pg_option_datestyle;\nadd_header option_default_transaction_read_only $pg_option_default_transaction_read_only;\nadd_header option_in_hot_standby $pg_option_in_hot_standby;\nadd_header option_integer_datetimes $pg_option_integer_datetimes;\nadd_header option_intervalstyle $pg_option_intervalstyle;\nadd_header option_is_superuser $pg_option_is_superuser;\nadd_header option_server_encoding $pg_option_server_encoding;\nadd_header option_server_version $pg_option_server_version;\nadd_header option_session_authorization $pg_option_session_authorization;\nadd_header option_standard_conforming_strings $pg_option_standard_conforming_strings;\nadd_header option_timezone $pg_option_timezone;\n```\n$pg_pid\n-------------\n* Syntax: $pg_pid\n\nBackend pid:\n```nginx\nadd_header pid $pg_pid;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frekgrpth%2Fngx_pg_module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frekgrpth%2Fngx_pg_module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frekgrpth%2Fngx_pg_module/lists"}