Skip to content

BUG: broken json for backup upstream for nginx 1.27.X (after upstream resolver public added) #318

@gleb-shchavlev

Description

@gleb-shchavlev

module version checks

  • I have checked that this issue has not already been reported.

Issue Description

VTS build from master.
nginx 1.27.5

config:

http {
  ...
  upstream resolver.local {
    zone clients 10m;
    server 127.0.0.1;
  }
  ...
  server {
    listen 80;
    location /vts {
      gzip on;
      gzip_types application/json;
      vhost_traffic_status_display;
      vhost_traffic_status_display_format html;
      vhost_traffic_status_bypass_stats on;
    }
  }
  upstream test {
    zone clients;
    server google.com:443 resolve;
    server www.google.com:443 backup resolve;
  }
  server {
    listen 777;
    location / {
      proxy_pass https://test;
    }
  }
  ...
}

Open 127.0.0.1/vts, all fine before console command:
curl 127.0.0.1:777

After got error in browser console:
VM141:1 Uncaught SyntaxError: Bad control character in string literal in JSON at position 16605 (line 1 column 16606) at JSON.parse (<anonymous>) at request.onload (vts:828:55)

In json block with server name for backup server is broken:
{ "server": "��",

The issue appears:

  1. If there is nginx with resolve command in upstream support
  2. If there is a backup server in the upstream block

Expected Behavior

Json does not broken.

Installed Versions

$ nginx -V
nginx version: nginx/1.27.5
built by gcc 11.5.0 20240719 (Red Hat 11.5.0-5) (GCC)
built with OpenSSL 3.3.3 11 Feb 2025
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-openssl=../openssl-openssl-3.3.3 --with-openssl-opt='--release enable-rc5 enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers enable-ktls -DOPENSSL_TLS_SECURITY_LEVEL=1' --with-http_realip_module --add-module=../nginx-module-vts --add-module=../nginx-vod-module-master --add-module=../headers-more-nginx-module-0.34 --add-module=../lua-nginx-module-master --add-module=../ngx_brotli-master --add-module=../encrypted-session-nginx-module-0.09 --add-module=../ngx_http_geoip2_module-3.4 --add-module=../redis2-nginx-module-0.15 --add-module=../set-misc-nginx-module-0.33 --add-module=../ngx_http_substitutions_filter_module-master --add-module=../nginx_accept_language_module-master --add-module=../njs-0.8.9/nginx --with-cc-opt='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

Reproducible Example nginx.conf

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions