Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The nginx documentation on "Configuration file measurement units" at says:

Sizes can be specified in bytes, kilobytes (suffixes k and K) or megabytes (suffixes m and M)

This is unclear, because kilobyte is officially defined as 1000 bytes and megabyte is officially defined as 1000000 bytes, but often it is used to mean 1024 bytes and 1024 * 1024 bytes respectively. Exactly what size kilobyte is used in the nginx configuration files? When the documentation says the default is 1m is that 1000000 or 1048576?

share|improve this question
When software says "kilobyte", assume 1024 unless stated otherwise. When hardware says "kilobyte", assume 1000 unless stated otherwise. – Shane Madden Oct 1 '13 at 22:49
up vote 5 down vote accepted

Looking at the source at (this is the version of ngx_parse.c in 1.5.6, but the function appears the same in the 0.3.53 version), it appears k or K represent 1024 bytes, that is, kibibytes (KiB) and m or M represents mebibytes (MiB), that is 1024 KiB.

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':
        scale = 1024;

    case 'M':
    case 'm':
        scale = 1024 * 1024;

        scale = 1;

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

    size *= scale;

    return size;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.