Welcome! Log In Create A New Profile

Advanced

Re: configuration of 1000's entries

Francis Daly
September 27, 2013 01:36PM
On Fri, Sep 27, 2013 at 04:22:25AM -0700, Shaun Savage wrote:

Hi there,

None of what follows is tested by me. So double-check before committing
to anything :-)

> I have many "virtual" paths on one nginx server. What I mean by this is
> there can be many top level paths, where each one has a cookie, static
> files, and a upstream server. The way I am doing it now is just
> duplicate every path.
>
> Is there a way to do this 'faster' 'less writing' 'better'? I am
> expecting 1000's of entries.

Faster for you to write, or faster for nginx to read and process?

Less writing for you, or for your "turn this input file into an
nginx.conf" script?


It looks like you could either auto-generate the conf file, so that it
will be big; or keep it small by using a (probably, nested) "location"
with regex and named captures.

After you have both, you can test your workload on your hardware to see
if there is a significant benefit of one over the other to you.

Or you can just make one, and see if your workload on your hardware is
handled well enough, and stop if it is.

The examples here look like there is a regular pattern to them. Assuming
that holds for all, then a simple template / macro system that does
a string replacement should work -- you keep your "real config" as a
list of a1, a2, etc; then run the script to generate the fragment of
nginx.conf that can be pasted in or "include"d.

Or you could try something like

==
location / {
location ~ ^/(?<bit>[^/]*)/exe {
# your "exe" stuff goes here, with $bit = a1 or a2
}
location ~ ^/(?<bit>[^/]*) {
# your "static" stuff goes here, with $bit = a1 or a2
}
}
==

but even with that, you're likely to want to auto-generate the "upstream"
sections externally to nginx anyway.

(You'll need other top-level location{} blocks for anything that should
not match the pattern you have shown, such as /login.)

All the "alias" lines you've shown look equivalent to a single "root
/var/www" at server-level -- that might simplify things, depending on
what else you plan to use the server for.

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

JSON REST APIs

Myla John-B22173 September 24, 2013 08:42PM

configuration of 1000's entries

sv September 27, 2013 07:24AM

Re: configuration of 1000's entries

Francis Daly September 27, 2013 01:36PM

extra ?

sv September 30, 2013 03:20AM

Re: extra ?

Maxim Dounin September 30, 2013 08:20AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 120
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready