Do nginx config files take kilobytes or kibibytes

Solution 1:

Looking at the source at http://hg.nginx.org/nginx/file/15056a29841a/src/core/ngx_parse.c (this is the version of ngx_parse.c in 1.5.6, but the function appears the same in the 0.3.53 version, and you can check the current version here), it appears k or K represent 1024 bytes, that is, kibibytes (KiB) and m or M represents mebibytes (MiB), that is 1024 KiB.

ssize_t
ngx_parse_size(ngx_str_t *line)
{
    u_char     unit;
    size_t     len;
    ssize_t    size;
    ngx_int_t  scale;

    len = line->len;
    unit = line->data[len - 1];

    switch (unit) {
    case 'K':
    case 'k':
        len--;
        scale = 1024;
        break;

    case 'M':
    case 'm':
        len--;
        scale = 1024 * 1024;
        break;

    default:
        scale = 1;
    }

    size = ngx_atosz(line->data, len);
    if (size == NGX_ERROR) {
        return NGX_ERROR;
    }

    size *= scale;

    return size;
}