2

I am looking for a "full NGINX solution", withou intermediary redirection... But I need some external processing by "my Name-Resolver", as illustred with this execute fantasy:

server {
  server_name resolver.mydomain.com;
  execute xx = http://localhos:123456/myNameResolver/$request_uri;
  rewrite ^ http://www.adifferentdomain.com$xx? permanent;
}

So, is possible to do something like this? perhaps using a kind of fastcgi_pass but only to return a string, not to bypass all HTTP resolution.

1

1 Answer 1

1

Well, you can use HttpLuaModule, which can execute commands and store them in variables if needed.

location / {
  server_name resolver.mydomain.com;
  # Get response via lua script.
  set_by_lua_file $xx 'resolver-script.lua' $request_uri;
  rewrite ^ http://www.adifferentdomain.com$xx? permanent;
}

You just need a Lua script to do your request for you, try something like this using your $request_uri as arg[1], because it is being considered as a command line argument

Sign up to request clarification or add additional context in comments.

6 Comments

But what the difference between LuaModule and usual Apache-modules or Nginx's fastcgi_pass used for PHP, Python, etc.? It is only a "language flavor", or HttpLuaModule is a real fast complement and low-overhead for Nginx's HTTP processing?
You need to do something that a webserver is not supposed to do, which is embedding a second request response in the response itself. This is usually done by some kind of application, or by using PHP, Python etc. Lua is just a "native" NGINX solution.
Ops, before discuss... How to send a parameter ($request_uri at my illustration) to the function-call used by $xx?
Is a good answer (!), only a final check. There are also a "native" NGINX JavaScript Module... Can I use set_by_js_file instead Lua? Or this magic is only offered by Lua?
Not exactly. Check out their API documentation down in the example section, maybe it will shed some light into your solution
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.