Issuing an HTTP request from a stream module

Roman Arutyunyan arut at nginx.com
Mon Apr 8 14:22:53 UTC 2019


Hi Eran,

On Mon, Apr 08, 2019 at 12:16:00PM +0000, Eran Kornblau wrote:
> Hi all,
> 
> I would like to issue HTTP requests from an nginx stream module.
> In my understanding, I need to use ngx_event_connect_peer to connect, and implement my own write/read event handlers
> in order to build the request/parse the response.

Yes.

> Is there some other solution that takes advantage of all the code that already exists in nginx for doing that?
> Also, does anyone happen to have some code that does something similar?

In nginx source there are at least 2 examples of how to write an HTTP client:

- OCSP stapling (src/event/ngx_event_openssl_stapling.c)
- mail_auth module (src/mail/ngx_mail_auth_http_module.c)

Also, the HTTP proxy module does this as well, but the entire module is much
more complicated.

-- 
Roman Arutyunyan


More information about the nginx-devel mailing list