A
A
Andrey Korvyakov2015-04-01 18:35:28
Nginx
Andrey Korvyakov, 2015-04-01 18:35:28

Does nginx create a separate tcp connection to an internal location?

Good day.
How it works:
1) The user accesses server 1 on server_name1/location1
2) It has a proxy_pass on upstream, server 2 from which sends a 302 redirect to another server_name2/location2 of server 1
3) We catch it (error_page 301 302 = @redirect; ) and send the content using the link obtained in step 2
Everything is transparent for the user, the url does not change.
In this case, nginx makes an http request to itself in step 3: server_name1/location1 -> server_name2/location2
The question is:
How does nginx access the internal location? With the creation of an additional tcp connection to itself or through internal mechanisms?
I would like to make a subrequest in server_name1/location1 to a third-party server 2, get a link and immediately make a proxy_pass for it

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Korvyakov, 2015-04-02
@LNShadow

Thanks everyone, everything was decided by rewrite to lua and transferring server_name2/location2 to server_name1/@redirect

P
polozad, 2015-04-01
@polozad

It's not nginx that's calling, it's the client that got the 302. Look at the logs, you can turn on the redirect trace there.

E
evnuh, 2015-04-01
@evnuh

Nihera is not clear, the terms themselves came up with. Give me config.
If nginx sees rewrite (redirect) then it just starts matching location from your config again but for a new url.
nginx.org/en/docs/http/ngx_http_rewrite_module.htm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question