Adding an nginx proxy in front of Victoria-Labs

Victoria-Logs has an built-in UI – and it’s easier for me to access via my web browser if I put Nginx in front of it.

In this post:

  • FreeBSD 15.0
  • victoria-logs-1.50.0_2
  • nginx-1.30.2_2,3/li>

Victoria Logs config

This is the main configuration, as found in /etc/rc.conf:

victoria_logs_args="-storageDataPath=/var/db/victoria-logs -retentionPeriod=1 \
-httpListenAddr=:9428 -syslog.listenAddr.tcp=:29514 -tls=true \
-tlsKeyFile=/usr/local/etc/ssl/logs.int.unixathome.org.key \
-tlsCertFile=/usr/local/etc/ssl/logs.int.unixathome.org.fullchain.cer"

Those \ and multiple lines, yea, don’t do that, put it all on one line. I’ve done that above to make it easier for you to read.

Nginx

This is what I added to my nginx.conf:

    # Define an upstream block for optimal connection pooling
    upstream victoria_backend {
        server 127.0.0.1:9428;
        keepalive 100;         # Keeps connections open to reduce TCP overhead
    }

    # HTTPS server
    #
    server {
        listen       443 ssl;
        server_name  logs.int.unixathome.org;

        ssl_certificate      /usr/local/etc/ssl/logs.int.unixathome.org.fullchain.cer;
        ssl_certificate_key  /usr/local/etc/ssl/logs.int.unixathome.org.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

    location / {
        proxy_pass https://victoria_backend;

        # Essential HTTP/1.1 settings for keepalive and high-performance ingestion
        proxy_http_version 1.1;
        proxy_set_header Connection "";

        # Standard proxy headers
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # Prevent premature timeouts during large data dumps or heavy queries
        proxy_connect_timeout 600s;
        proxy_send_timeout    600s;
        proxy_read_timeout    600s;
        send_timeout          600s;

        # Optimize buffers for handling larger query responses and log streams
        proxy_buffer_size 128k;
        proxy_buffers 4 256k;
        proxy_busy_buffers_size 256k;
    }
    }

}

Hope that gets you started.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top