Forum: NGINX Insert Variable Values when loading a Cloud Config?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
De7b680154f831d87d8ea48743852f14?d=identicon&s=25 leeand00 (Guest)
on 2016-07-11 15:41
(Received via mailing list)
I asked a question on another site
(http://stackoverflow.com/questions/37032806/does-b...)
about loading a cloud config from nginx onto a bare-metal core-os
machine.


The question involves trying to have nginx fill in the variables for the
$private_ipv4 and $public_ipv4 when a config is loaded up.  Does this
require that I use php-fpm to somehow recognize the machine sending the
request, and then fill in the variables when the cloud-config is
requested?

Posted at Nginx Forum:
https://forum.nginx.org/read.php?2,268241,268241#msg-268241
36a8284995fa0fb82e6aa2bede32adac?d=identicon&s=25 Francis Daly (Guest)
on 2016-07-11 20:31
(Received via mailing list)
On Mon, Jul 11, 2016 at 09:40:45AM -0400, leeand00 wrote:

Hi there,

> The question involves trying to have nginx fill in the variables for the
> $private_ipv4 and $public_ipv4 when a config is loaded up.  Does this
> require that I use php-fpm to somehow recognize the machine sending the
> request, and then fill in the variables when the cloud-config is requested?

I think that the nginx side of the question is:

A file exists on the filesystem. A request is made for the matching
url. Can nginx return the file contents, making some textual
substitutions
in the file contents?

If that is the question, then the answers probably involves: does nginx
know what the desired substitutions are? (As in, where do the suitable
values for $private_ipv4 and $public_ipv4 come from?)

If nginx can know, then probably the sub_filter module
(http://nginx.org/r/sub_filter) can help.

You made need to check that you can include a literal $ in the string
to replace, but that should be a straightforward enough test after you
know that nginx can know what the replacement strings are.

If sub_filter is not suitable, then you could use any other active
content
system (such as php-fpm) to do the work. The details will matter.

Good luck with it,

  f
--
Francis Daly        francis@daoine.org
De7b680154f831d87d8ea48743852f14?d=identicon&s=25 leeand00 (Guest)
on 2016-07-12 03:24
(Received via mailing list)
This is just a guess, but probably a hashap...or maybe a DNS server that
assigns them statically.  But I suppose CoreOS has to request it from
nginx,
so it could probably even just pull it out of the request.

Posted at Nginx Forum:
https://forum.nginx.org/read.php?2,268241,268250#msg-268250
36a8284995fa0fb82e6aa2bede32adac?d=identicon&s=25 Francis Daly (Guest)
on 2016-07-12 22:16
(Received via mailing list)
On Mon, Jul 11, 2016 at 09:24:11PM -0400, leeand00 wrote:

Hi there,

> This is just a guess, but probably a hashap...or maybe a DNS server that
> assigns them statically.  But I suppose CoreOS has to request it from nginx,
> so it could probably even just pull it out of the request.

When you can see what the request is, and what information it includes,
and when you can see how nginx-or-something-else can take that
information
and determine the correct public and private addresses to use, then you
may have enough information to configure sub_filter (or something else)
to return the content that you want.

Most of those missing pieces are not nginx-specific.

There might be someone here who knows about them; but if they are
CoreOS-specific, you may have better luck on a CoreOS list.

Good luck with it,

  f
--
Francis Daly        francis@daoine.org
This topic is locked and can not be replied to.