4

For quite some time now nginx gives me this warning:

nginx: [warn] could not build optimal variables_hash, you should increase either variables_hash_max_size: 1024 or variables_hash_bucket_size: 64; ignoring variables_hash_bucket_size

However in the http block of my config I have this:

http {
  # More config...

  variables_hash_max_size 1024;
  variables_hash_bucket_size 64;

  # More config...
}

(Increasing to higher values doesn't solve it either! Also I ran nginx -T and checked if these keys were set to a different value, which they were not!)
How do I solve this?

(If required I will post more of the config. I'm just not sure which parts are relevant.)

BrainStone
  • 103
  • 1
  • 1
  • 9

2 Answers2

2

You mentioned...

and checked if these keys were set to a different value, which they were not!

Was that just spot-checking that declarative, or did you grep the config files? I would do the latter to ensure it isn't declared somewhere else as well.

Paste the results of nginx -V.

Do you have any extra modules enabled? How high a value did you try? It's possible that you either have modules adding to the variable weight or you have a lot (or lengthy values) declared.

Ulfy
  • 351
  • 1
  • 5
  • `nginx -T` print the entire config. So grepping that I am certain that it is not influenced by another value. – BrainStone Jul 13 '17 at 10:47
  • `-t` checks for syntactical correctness. I just wanted to verify your grepped the config to ensure it isn't elsewhere. Can you paste the `-V` results? I wanted to see that to get a feel for how many modules were being loaded. – Ulfy Jul 13 '17 at 13:41
  • That's why I used `-T` (not `-t`) which prints the entire config. – BrainStone Jul 13 '17 at 13:42
  • That's fine, I was just asking for clarity since you never said if you grepped the config in the first place, only that "you checked". At any rate, the error you're getting can be legit if your variable load is too great, which can happen with extra modules. – Ulfy Jul 13 '17 at 13:51
  • 1
    Increasing the values further soved the issue. Thanks for pointing me in this direction! – BrainStone Jul 13 '17 at 21:52
0

The warning message shows the current value, not the suggested value.

In case you get this warning, you should set the value to double its existing value, which should be a power of 2. Hence variables_hash_max_size 2048; should work.

Ref: NGINX documentation

K M
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 15 '22 at 07:03