Skip to content

Commit 858596d

Browse files
committed
Allow HTTP scheme in endpoint (fix #60).
1 parent b5c8cd8 commit 858596d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/http_module.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ ngx_str_t toNgxStr(StrView str)
144144
return ngx_str_t{str.size(), (u_char*)str.data()};
145145
}
146146

147+
bool iremovePrefix(ngx_str_t* str, StrView p)
148+
{
149+
if (str->len >= p.size() &&
150+
ngx_strncasecmp(str->data, (u_char*)p.data(), p.size()) == 0) {
151+
str->data += p.size();
152+
str->len -= p.size();
153+
return true;
154+
}
155+
156+
return false;
157+
}
158+
147159
MainConf* getMainConf(ngx_conf_t* cf)
148160
{
149161
return static_cast<MainConf*>(
@@ -658,6 +670,14 @@ char* setExporter(ngx_conf_t* cf, ngx_command_t* cmd, void* conf)
658670
return rv;
659671
}
660672

673+
if (iremovePrefix(&mcf->endpoint, "https://")) {
674+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
675+
"\"otel_exporter\" doesn't support \"https\" endpoints");
676+
return (char*)NGX_CONF_ERROR;
677+
} else {
678+
iremovePrefix(&mcf->endpoint, "http://");
679+
}
680+
661681
if (mcf->endpoint.len == 0) {
662682
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
663683
"\"otel_exporter\" requires \"endpoint\"");

0 commit comments

Comments
 (0)