Read configuration at runtime

I want to make nginx to get different configurations dynamically at
runtime.

Appreciate for any suggestions.

On Tue, Aug 26, 2008 at 12:58:14PM +0000, Jarod B. wrote:

I want to make nginx to get different configurations dynamically at runtime.

what is wrong with nginx -c /path/to/configuration/file.conf ?

Almir K. <almir@…> writes:

On Tue, Aug 26, 2008 at 12:58:14PM +0000, Jarod B. wrote:

I want to make nginx to get different configurations dynamically at runtime.

what is wrong with nginx -c /path/to/configuration/file.conf ?

Excuse me, What I wanted to know is when nginx have been already
running, how
to read any other configurations(such as different user’s configuration)
in the
runtime.

I think this need some ngx_http_module hacking, but I need some guide,
since
I’m not familiar enough with nginx’s internal architecture.

Thank you for your reply. :slight_smile:

Hi,

kill -HUP pidof nginx

http://wiki.codemongers.com/NginxCommandLine#utnbotf

Best regards

2008/8/26 Jarod B. [email protected]

Hi Jarod,

If you mean in the way Apache reads .htaccess files, then as far as I
understand, there isn’t really any support for this in nginx; it reads
its config at startup, and as Andre says, you need to tell it to
reload the config using a signal.

Cheers,
Igor

On Tue, Aug 26, 2008 at 02:23:57PM +0000, Jarod B. wrote:

Excuse me, What I wanted to know is when nginx have been already running, how
to read any other configurations(such as different user’s configuration) in the
runtime.

I think this need some ngx_http_module hacking, but I need some guide, since
I’m not familiar enough with nginx’s internal architecture.

Thank you for your reply. :slight_smile:

nginx supports HUP, once you modify it’s config file just do something
ala:

pkill -1 nginx

and it should re-read the config file.

Andre Arnold <andre.arnold@…> writes:

Hi,kill -HUP pidof nginxhttp://wiki.codemongers.com/
NginxCommandLine#utnbotfBest regards
2008/8/26 Jarod B. [email protected]
Almir K. <almir …> writes:

On Tue, Aug 26, 2008 at 12:58:14PM +0000, Jarod B. wrote:

I want to make nginx to get different configurations dynamically at
runtime.

what is wrong with nginx -c /path/to/configuration/file.conf ?

Excuse me, What I wanted to know is when nginx have been already running, how
to read any other configurations(such as different user’s configuration) in
the
runtime.
I think this need some ngx_http_module hacking, but I need some guide, since
I’m not familiar enough with nginx’s internal architecture.
Thank you for your reply. :slight_smile:

Oh, my bad english, It seems I need to explain my question more
carefully.

In fact, I mean:

There are some sub-conf-file asid from a main-conf-file, when nginx
start, it
will load the main-conf-file at first.
When nginx is running, if it gets any requests and matchs a
sub-conf-file by
some rules, the main process will load this sub-conf-file to application
runtime.

Anyway, thank you all. :slight_smile:

Igor C. <igor@…> writes:

Hi Jarod,
If you mean in the way Apache reads .htaccess files, then as far as I
understand, there isn’t really any support for this in nginx; it reads
its
config at startup, and as Andre says, you need to tell it to reload the
config
using a signal.

Cheers,
Igor

On 26 Aug 2008, at 15:32, Andre Arnold wrote:
Hi,kill -HUP pidof nginxhttp://wiki.codemongers.com/
NginxCommandLine#utnbotfBest regards 2008/8/26 Jarod B. <jarodbelle-
[email protected]> Almir K. <almir …>
writes: >
On Tue, Aug 26, 2008 at 12:58:14PM +0000, Jarod B. wrote: > > I want to
make nginx to get different configurations dynamically at runtime. > >
what is
wrong with nginx -c /path/to/configuration/file.conf ? >
Excuse me, What I wanted to know is when nginx have been already running, how
to read any other configurations(such as different user’s configuration)
in the
runtime. I think this need some ngx_http_module hacking, but I need some
guide,
since I’m not familiar enough with nginx’s internal architecture. Thank
you for
your reply. :slight_smile:


Igor C. • POKE • 10 Redchurch Street • E2 7DD • +44 (0)20 7749 5355 •
www.pokelondon.com

Yes, I mean it.

So sadly, but I really need to implement this function for some reason.

Is it possible that just do some hacking job on http moudle?

I have already read a part of nginx’s source code, but still can not
figure it
out.

What’s going to change the config file and how often? If it’s being
updated by some other process or script then perhaps it’s easier to just
have that script send a signal to Nginx. Only case where this seems
like it wouldn’t be workable is if you are updating these configs
continuously and don’t want Nginx reloading it’s config every second or
so. But I mean, if you’re thinking that a config will change a few times
a day or week then a scripted signal on change would give you the
results you need.
Chris :slight_smile:

On Tue, Aug 26, 2008 at 03:15:10PM +0000, Jarod B. wrote:

Yes, I mean it.

So sadly, but I really need to implement this function for some reason.

Is it possible that just do some hacking job on http moudle?

I have already read a part of nginx’s source code, but still can not figure it
out.

It’s possible, but requires too many code changes: nginx was designed
to parse and compile configuration before run-time.

Igor S., thanks boss, then I think it’s a hard way for me and the
hard
job should belong to you. :slight_smile:

Thanks for your time and this great product.

Chris,

Yeah, your advice is pretty cool. I think I should implement a
management
CGI of conf-file, instead of to hack source code.

Thank you very much. :slight_smile:

On Wed, 27 Aug 2008 01:56:58 +0800, Chris S.
[email protected] wrote:

Is it possible to add a management interface in nginx to change the
config on the fly.
But how to deal with the multiple worker process ,use share memory in
main process?

2008/8/27 Chris S. [email protected]: