./nginx -V
nginx version: nginx/1.16.1 built by clang 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512 built with OpenSSL 1.0.2j 26 Sep 2016 TLS SNI support enabled configure arguments: –prefix=/opt/nginx –with-pcre=/home/user/pcre-8.40 –with-zlib=/home/user/zlib-1.2.11 –with-openssl=/home/user/openssl-1.0.2j –with-http_ssl_module –with-http_realip_module –with-http_stub_status_module –with-http_secure_link_module –add-module=/home/user/njs/nginx –with-http_sub_module
конфиг без воды относящийся к делу
location /doc
{
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log logs/443.doc.access.log up_log;
error_log logs/443.doc.error.log;
client_max_body_size 50M;
subrequest_output_buffer_size 100M;
js_content write_body;
}
location /NJSNJS/doc
{
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log logs/443.doc_njs.access.log up_log;
error_log logs/443.doc_njs.error.log;
client_max_body_size 50M;
subrequest_output_buffer_size 100M;
proxy_pass https://10.2.11.1/doc;
}
function write_body (r) {
var TOURI = "/NJSNJS" + r.variables.request_uri;
// if ( 0 )
if ( 1 )
{
var HEADERS = "";
var h;
for (h in r.headersIn) {
HEADERS += " header '" + h + "' is '" + r.headersIn[h] + "'\n";
}
r.subrequest(TOURI, { method: r.method }, function logging(res)
{
var dater;
dater = "\n\n========== " + r.variables.time_local + " =========="; //Date of the request
if ( res.status == "301" || res.status == "302" || res.status == "303" || res.status == "307" || res.status == "308")
{
r.return (res.status, r.variables.http_location);
}
else
{
r.return (res.status, res.responseBody);
}
var HEADERSOUT = "";
var g;
for (g in r.headersOut) {
HEADERSOUT += " header '" + g + "' is '" + r.headersOut[g] + "'\n";
}
var BODY = "Source IP - " + r.remoteAddress + " Method - " + r.method + " Status - " + res.status + " URI - " + r.variables.request_uri + "\n" + " Headers in " + "\n" + HEADERS + "\n Headers out\n" + HEADERSOUT + "\nRequest body - " + r.requestBody + "\nResponse body - " + res.responseBody;
var messageTOlog = dater + "\n" + BODY;
var fs = require('fs');
var filename = "/opt/nginx/logs/BODY.txt";
fs.appendFileSync(filename, messageTOlog, { encoding: 'utf8' });
}
);
}
else
{
r.internalRedirect(TOURI);
}
}
Если идти по ветке else (т.е. без подзапроса) то хедеры присутствуют в полном объеме, если идти по пути подзапроса то хедеров нет, что видно и по вгету и по логированию. В случае 301 302 итд хедер Location есть, но пустой, что неприемлемо. Доки 3 раза уже перечитал, гугл тоже, уже подозреваю что баг в njs.