Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/fluent-bit/flb_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ struct flb_net_setup {

/* maximum number of allowed active TCP connections */
int max_worker_connections;

/* If true, ignore HTTP_PROXY, NO_PROXY, etc. */
int proxy_env_ignore;
};

/* Defines a host service and it properties */
Expand Down
1 change: 1 addition & 0 deletions src/flb_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ void flb_net_setup_init(struct flb_net_setup *net)
net->io_timeout = 0; /* Infinite time */
net->source_address = NULL;
net->backlog = FLB_NETWORK_DEFAULT_BACKLOG_SIZE;
net->proxy_env_ignore = FLB_FALSE;
}

int flb_net_host_set(const char *plugin_name, struct flb_net_host *host, const char *address)
Expand Down
29 changes: 29 additions & 0 deletions src/flb_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,35 @@ int flb_output_upstream_set(struct flb_upstream *u, struct flb_output_instance *
/* Set networking options 'net.*' received through instance properties */
memcpy(&u->base.net, &ins->net_setup, sizeof(struct flb_net_setup));

/*
* If the Upstream was created using a proxy from the environment but the
* final configuration asks to ignore environment proxy variables, restore
* the original destination host information.
*/
if (u->base.net.proxy_env_ignore == FLB_TRUE && u->proxied_host) {
flb_free(u->tcp_host);
u->tcp_host = flb_strdup(u->proxied_host);
u->tcp_port = u->proxied_port;

flb_free(u->proxied_host);
u->proxied_host = NULL;
u->proxied_port = 0;

/*
* Credentials are only set when the connection was configured via environment
* variables. Since we just reverted the upstream to the destination configured
* by the plugin, drop any credentials that may have been parsed.
*/
if (u->proxy_username) {
flb_free(u->proxy_username);
u->proxy_username = NULL;
}
if (u->proxy_password) {
flb_free(u->proxy_password);
u->proxy_password = NULL;
}
}

return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions src/flb_upstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ struct flb_config_map upstream_net[] = {
"Set the maximum number of active TCP connections that can be used per worker thread."
},

{
FLB_CONFIG_MAP_BOOL, "net.proxy_env_ignore", "FALSE",
0, FLB_TRUE, offsetof(struct flb_net_setup, proxy_env_ignore),
"Ignore the environment variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY when "
},

/* EOF */
{0}
};
Expand Down
Loading