在NGINX中使用Postgres Basic Auth将查询结果添加到代理HTTP头
我们正在尝试使用ngx_postgres模块通过NGINX进行基本authentication。 我们希望从查询结果对中检索一个值并将其添加到HTTP头,然后将其代理到另一个服务器。 我们已经成功通过postgres进行身份validation,但问题是已经将结果对传递给代理。 我们目前使用的代码如下: location = /test_auth { internal; postgres_escape $user $remote_user; postgres_escape $pass $remote_passwd; postgres_pass geo_database; postgres_query "select user_name,contract_id,access_token from schema_name.table_name where user_name=$user and password=md5($pass);"; postgres_rewrite no_rows 401; more_set_headers -s 401 'WWW-Authenticate: Basic realm="Restricted"'; postgres_output none; postgres_set $query_val 0 0 required; } location /test/ { auth_request /test_auth; proxy_pass http://back_end_server/public-dev/; proxy_set_header test $query_val; proxy_redirect http://back_end_server/public-dev/ […]