diff --git a/lib/context.c b/lib/context.c
index 88e7fe4557c35b8632791a81cbf5a806c9442a6e..2a56c6962489242dbf495c2c67b8366125913b67 100644
--- a/lib/context.c
+++ b/lib/context.c
@@ -606,6 +606,9 @@ lws_create_context(struct lws_context_creation_info *info)
 		context->pt_serv_buf_size = 4096;
 
 	context->reject_service_keywords = info->reject_service_keywords;
+	if (info->external_baggage_free_on_destroy)
+		context->external_baggage_free_on_destroy =
+			info->external_baggage_free_on_destroy;
 
 	context->time_up = time(NULL);
 #ifndef LWS_NO_DAEMONIZE
@@ -960,5 +963,8 @@ lws_context_destroy(struct lws_context *context)
 
 	lws_plat_context_late_destroy(context);
 
+	if (context->external_baggage_free_on_destroy)
+		free(context->external_baggage_free_on_destroy);
+
 	lws_free(context);
 }
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index 8a2ae4be1f966bbf6aa1373a66420641634a25f6..489db6f84a1cd89b3063a0816ab720201986aa29 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -1715,6 +1715,13 @@ struct lws_context_creation_info {
 	 *
 	 * Eg, "badrobot" "404 Not Found"
 	 */
+	void *external_baggage_free_on_destroy;
+	/**< CONTEXT: NULL, or pointer to something externally malloc'd, that
+	 * should be freed when the context is destroyed.  This allows you to
+	 * automatically sync the freeing action to the context destruction
+	 * action, so there is no need for an external free() if the context
+	 * succeeded to create.
+	 */
 
 	/* Add new things just above here ---^
 	 * This is part of the ABI, don't needlessly break compatibility
diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index 6a3ad8cb697993e5648556785e27126df31173da..346abbdd73da87caf018019bfb152c0efba4a0c5 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -833,6 +833,7 @@ struct lws_context {
 #endif
 	struct lws_vhost *vhost_list;
 	struct lws_plugin *plugin_list;
+	void *external_baggage_free_on_destroy;
 	const struct lws_token_limits *token_limits;
 	void *user_space;
 	const char *server_string;
diff --git a/lwsws/main.c b/lwsws/main.c
index b4979192bce76cae68c179e871e71592b035c776..f948878905851312a0afb4b6694395cf26b92066 100644
--- a/lwsws/main.c
+++ b/lwsws/main.c
@@ -161,6 +161,7 @@ int main(int argc, char **argv)
 
 	memset(&info, 0, sizeof(info));
 
+	info.external_baggage_free_on_destroy = config_strings;
 	info.max_http_header_pool = 16;
 	info.options = opts | LWS_SERVER_OPTION_VALIDATE_UTF8 |
 			      LWS_SERVER_OPTION_EXPLICIT_VHOSTS |
@@ -200,7 +201,6 @@ int main(int argc, char **argv)
 	}
 
 	lws_context_destroy(context);
-	free(config_strings);
 
 	fprintf(stderr, "lwsws exited cleanly\n");