Answer the question
In order to leave comments, you need to log in
Can I read data in Nginx?
Let's say I have a dictionary like this:
dictionary = {
'apple':8080,
'car':8081,
'pear':8082
}
Answer the question
In order to leave comments, you need to log in
You can, for this there is a map
construct
that even knows how to pull options from a separate file
. However, this is a rather static option, suitable for cases where you just need to set it up and forget it.
If you need interactivity, then you can try to add it through the njs module - it allows you to write js code that sets the value of a variable.
However, this is a rather atypical option and 99% of its uses are crutches and bicycles.
In the case when you need proxying to a dynamically generated list of services, look towards various custom proxies and service discovery, such as HAProxy or Consul.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question