Welcome! Log In Create A New Profile

Advanced

XML with nginx

Posted by rfocus_streamer 
XML with nginx
May 18, 2015 03:11AM
Is possible to use xml file to read some string for nginx proxy_pass ?



Edited 1 time(s). Last edit at 05/18/2015 03:11AM by rfocus_streamer.
Re: XML with nginx
May 18, 2015 04:04AM
Using Lua you can read anything, convert and set variables.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: XML with nginx
May 18, 2015 04:25AM
Can you give me some example with lua ?
Re: XML with nginx
May 18, 2015 04:38AM
https://www.google.nl/#q=nginx+lua+read+xml

http://viremo.eludi.net/LuaXML/

And then do something in a location block like:

set_by_lua $notused '
ngx.var.myroot = "default value";
if myuri == "www" then ngx.var.myroot = "someothervalue"; end;
';

But then of-course with a variable to be used in proxy_pass.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: XML with nginx
May 18, 2015 09:05AM
My xml is on local disk in c:/mystring.xml with this lines :

<Streamer>

<StringText>SomeURL</StringText>

</Streamer>

Please if you can show me how can I get text from StringText attribute ?
Re: XML with nginx
May 18, 2015 10:28AM
You read the file into an array,

dsarr = {};
local file = io.open("file.txt", "r");
for i = 1, count, 1 do
ds_line = file:read();
table.insert (dsarr, ds_line);

And while reading you could parse the line or later parse the array.

Though at http://viremo.eludi.net/LuaXML/ is a good example of using a library and being able to get a value from a xml attribute, once you have a variable simple do something like "ngx.var.myprox = xmlvar;"
inside nginx you do then proxy_pass $myprox;

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 176
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready