diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9471b3ea19c5e347863c68452d8967187c05c023..621be518fdd2a315b23a8753ab50f58d45d11e7a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -312,11 +312,16 @@ if (NOT LWS_HAVE_REALLOC)
 	set(realloc rpl_realloc)
 endif()
 
-# Generate the lws_config.h that includes all the compilation settings.
+# Generate the lws_config.h that includes all the public compilation settings.
 configure_file(
        "${PROJECT_SOURCE_DIR}/lws_config.h.in"
        "${PROJECT_BINARY_DIR}/lws_config.h")
 
+# Generate the lws_config.h that includes all the private compilation settings.
+configure_file(
+       "${PROJECT_SOURCE_DIR}/lws_config_private.h.in"
+       "${PROJECT_BINARY_DIR}/lws_config_private.h")
+
 if (MSVC)
 	# Turn off stupid microsoft security warnings.
 	add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index e79b25afd294f00cf90ca9e051d39823b54b046a..c621029d480c2e1656b7d27879d97307e6df6a22 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -30,7 +30,6 @@ extern "C" {
 #include <stdarg.h>
 #endif
 
-/* That's a bad idea since it will leak all internal defines outside */
 #include "lws_config.h"
 
 #if defined(WIN32) || defined(_WIN32)
diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index 85e750be959be74cb8afc076e62b49cf4d1d887b..ec08013527a173a3e206e24f42aa3bc70d35e38e 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -20,6 +20,7 @@
  */
 
 #include "lws_config.h"
+#include "lws_config_private.h"
 
 #ifdef LWS_HAVE_SYS_TYPES_H
 #include <sys/types.h>
diff --git a/lws_config.h.in b/lws_config.h.in
index 64db165e65aba5836f7754489a76d73cec0fff1b..65331b931c9231191c727e00909f7feb26d88e52 100644
--- a/lws_config.h.in
+++ b/lws_config.h.in
@@ -59,107 +59,3 @@
 /* Use the BSD getifaddrs that comes with libwebsocket, for uclibc support */
 #cmakedefine LWS_BUILTIN_GETIFADDRS
 
-/* Define to 1 if you have the `bzero' function. */
-#cmakedefine LWS_HAVE_BZERO
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#cmakedefine LWS_HAVE_DLFCN_H
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#cmakedefine LWS_HAVE_FCNTL_H
-
-/* Define to 1 if you have the `fork' function. */
-#cmakedefine LWS_HAVE_FORK
-
-/* Define to 1 if you have the `getenv’ function. */
-#cmakedefine LWS_HAVE_GETENV
-
-/* Define to 1 if you have the <in6addr.h> header file. */
-#cmakedefine LWS_HAVE_IN6ADDR_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#cmakedefine LWS_HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `ssl' library (-lssl). */
-//#cmakedefine LWS_HAVE_LIBSSL
-
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
-   to 0 otherwise. */
-#cmakedefine LWS_HAVE_MALLOC
-
-/* Define to 1 if you have the <memory.h> header file. */
-#cmakedefine LWS_HAVE_MEMORY_H
-
-/* Define to 1 if you have the `memset' function. */
-#cmakedefine LWS_HAVE_MEMSET
-
-/* Define to 1 if you have the <netinet/in.h> header file. */
-#cmakedefine LWS_HAVE_NETINET_IN_H
-
-/* Define to 1 if your system has a GNU libc compatible `realloc' function,
-   and to 0 otherwise. */
-#cmakedefine LWS_HAVE_REALLOC
-
-/* Define to 1 if you have the `socket' function. */
-#cmakedefine LWS_HAVE_SOCKET
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#cmakedefine LWS_HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#cmakedefine LWS_HAVE_STDLIB_H
-
-/* Define to 1 if you have the `strerror' function. */
-#cmakedefine LWS_HAVE_STRERROR
-
-/* Define to 1 if you have the <strings.h> header file. */
-#cmakedefine LWS_HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#cmakedefine LWS_HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/prctl.h> header file. */
-#cmakedefine LWS_HAVE_SYS_PRCTL_H
-
-/* Define to 1 if you have the <sys/socket.h> header file. */
-#cmakedefine LWS_HAVE_SYS_SOCKET_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#cmakedefine LWS_HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#cmakedefine LWS_HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#cmakedefine LWS_HAVE_UNISTD_H
-
-/* Define to 1 if you have the `vfork' function. */
-#cmakedefine LWS_HAVE_VFORK
-
-/* Define to 1 if you have the <vfork.h> header file. */
-#cmakedefine LWS_HAVE_VFORK_H
-
-/* Define to 1 if `fork' works. */
-#cmakedefine LWS_HAVE_WORKING_FORK
-
-/* Define to 1 if `vfork' works. */
-#cmakedefine LWS_HAVE_WORKING_VFORK
-
-/* Define to 1 if you have the <zlib.h> header file. */
-#cmakedefine LWS_HAVE_ZLIB_H
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
-#undef LT_OBJDIR // We're not using libtool
-
-/* Define to rpl_malloc if the replacement function should be used. */
-#cmakedefine malloc
-
-/* Define to rpl_realloc if the replacement function should be used. */
-#cmakedefine realloc
-
-/* Define to 1 if we have getifaddrs */
-#cmakedefine LWS_HAVE_GETIFADDRS
-
-/* Define if the inline keyword doesn't exist. */
-#cmakedefine inline ${inline}
diff --git a/lws_config_private.h.in b/lws_config_private.h.in
new file mode 100644
index 0000000000000000000000000000000000000000..06da558c1cc587023659c61c531b157e486e2654
--- /dev/null
+++ b/lws_config_private.h.in
@@ -0,0 +1,118 @@
+/* lws_config_private.h.in. Private compilation options. */
+
+#ifndef NDEBUG
+	#ifndef _DEBUG
+		#define _DEBUG
+	#endif
+#endif
+
+/* Define to 1 to use CyaSSL as a replacement for OpenSSL. 
+ * LWS_OPENSSL_SUPPORT needs to be set also for this to work. */
+#cmakedefine USE_CYASSL
+
+/* Define to 1 if you have the `bzero' function. */
+#cmakedefine LWS_HAVE_BZERO
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#cmakedefine LWS_HAVE_DLFCN_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#cmakedefine LWS_HAVE_FCNTL_H
+
+/* Define to 1 if you have the `fork' function. */
+#cmakedefine LWS_HAVE_FORK
+
+/* Define to 1 if you have the `getenv’ function. */
+#cmakedefine LWS_HAVE_GETENV
+
+/* Define to 1 if you have the <in6addr.h> header file. */
+#cmakedefine LWS_HAVE_IN6ADDR_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine LWS_HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `ssl' library (-lssl). */
+//#cmakedefine LWS_HAVE_LIBSSL
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+   to 0 otherwise. */
+#cmakedefine LWS_HAVE_MALLOC
+
+/* Define to 1 if you have the <memory.h> header file. */
+#cmakedefine LWS_HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#cmakedefine LWS_HAVE_MEMSET
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#cmakedefine LWS_HAVE_NETINET_IN_H
+
+/* Define to 1 if your system has a GNU libc compatible `realloc' function,
+   and to 0 otherwise. */
+#cmakedefine LWS_HAVE_REALLOC
+
+/* Define to 1 if you have the `socket' function. */
+#cmakedefine LWS_HAVE_SOCKET
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#cmakedefine LWS_HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#cmakedefine LWS_HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strerror' function. */
+#cmakedefine LWS_HAVE_STRERROR
+
+/* Define to 1 if you have the <strings.h> header file. */
+#cmakedefine LWS_HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#cmakedefine LWS_HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/prctl.h> header file. */
+#cmakedefine LWS_HAVE_SYS_PRCTL_H
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#cmakedefine LWS_HAVE_SYS_SOCKET_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#cmakedefine LWS_HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#cmakedefine LWS_HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#cmakedefine LWS_HAVE_UNISTD_H
+
+/* Define to 1 if you have the `vfork' function. */
+#cmakedefine LWS_HAVE_VFORK
+
+/* Define to 1 if you have the <vfork.h> header file. */
+#cmakedefine LWS_HAVE_VFORK_H
+
+/* Define to 1 if `fork' works. */
+#cmakedefine LWS_HAVE_WORKING_FORK
+
+/* Define to 1 if `vfork' works. */
+#cmakedefine LWS_HAVE_WORKING_VFORK
+
+/* Define to 1 if you have the <zlib.h> header file. */
+#cmakedefine LWS_HAVE_ZLIB_H
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#undef LT_OBJDIR // We're not using libtool
+
+/* Define to rpl_malloc if the replacement function should be used. */
+#cmakedefine malloc
+
+/* Define to rpl_realloc if the replacement function should be used. */
+#cmakedefine realloc
+
+/* Define to 1 if we have getifaddrs */
+#cmakedefine LWS_HAVE_GETIFADDRS
+
+/* Define if the inline keyword doesn't exist. */
+#cmakedefine inline ${inline}
+
+
diff --git a/test-server/test-client.c b/test-server/test-client.c
index 624e2bf52da1bf743367fcec69e022cbd4376c39..5d3b68041ef803c5eacae728cdaad7a4b54a2d14 100644
--- a/test-server/test-client.c
+++ b/test-server/test-client.c
@@ -31,8 +31,6 @@
 #include <unistd.h>
 #endif
 
-#include "lws_config.h"
-
 #include "../lib/libwebsockets.h"
 
 static unsigned int opts;
diff --git a/test-server/test-echo.c b/test-server/test-echo.c
index e26e4772aa892ccb945bff26b2e672107c90126f..77795c5f57b23b2df8b07dd6b6e5c6164da88f56 100644
--- a/test-server/test-echo.c
+++ b/test-server/test-echo.c
@@ -35,8 +35,6 @@
 #include <unistd.h>
 #endif
 
-#include "lws_config.h"
-
 #include "../lib/libwebsockets.h"
 
 static volatile int force_exit = 0;
diff --git a/test-server/test-ping.c b/test-server/test-ping.c
index fefca31d5093d8efea6f602d806fe6b024d9bff0..f414b08805ffde8a04dbac9dffc03982431c3ca6 100644
--- a/test-server/test-ping.c
+++ b/test-server/test-ping.c
@@ -35,8 +35,6 @@
 #include <unistd.h>
 #endif
 
-#include "lws_config.h"
-
 #include "../lib/libwebsockets.h"
 
 /*