nginx / njs

A subset of JavaScript language to use in nginx
http://nginx.org/en/docs/njs/
BSD 2-Clause "Simplified" License
1.17k stars 152 forks source link

unknown directive "js_fetch_trusted_certificate" but js_import, js_content work #788

Closed remember-to-change-this closed 1 month ago

remember-to-change-this commented 1 month ago

Describe the bug

I've build njs module from source ensuring nginx 1.25.5 and njs 0.8.5 but I cant figure out why some directives are working and others are not found, specifically the "js_fetch_trusted_certificate" as I need to use ngx.fetch to a https endpoint. Any ideas on what I'm missing?

To reproduce

Expected behavior

Expected no error and ngx.fetch to work with my https:// endpoint. Without this directive the error "client sent plain HTTP request to HTTPS port while reading client request headers" shows.

Your environment

xeioex commented 1 month ago

Hi @remember-to-change-this,

It seems that you built modules without openssl available. See this ifdef. At the same time I see --with-http_ssl_module in your nginx -V, this is a bit strange. Anyway NGX_HTTP_SSL was not defined at the moment of the module compilation.

remember-to-change-this commented 1 month ago

Thanks so much @xeioex that was exactly the problem. I had a multi-stage build in my dockerfile so the output above didnt reflect the image during build stage. Needed to add --with-http_ssl_module, thanks again.