diff --git a/Makefile b/Makefile index befa3a3..ee5b022 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -CFLAGS=-std=c11 -Wall +CFLAGS=-std=gnu11 -Wall INCLUDE=-lssl -lcrypto -lmagic -lz -lmaxminddb -lbrotlienc LIBS=src/lib/*.c diff --git a/src/lib/rev_proxy.c b/src/lib/rev_proxy.c index 1f6e5b1..b629dcd 100644 --- a/src/lib/rev_proxy.c +++ b/src/lib/rev_proxy.c @@ -192,12 +192,15 @@ int rev_proxy_init(http_req *req, http_res *res, host_config *conf, sock *client goto proxy_err; } - struct hostent *host_ent = gethostbyname(conf->rev_proxy.hostname); + struct hostent *host_ent = gethostbyname2(conf->rev_proxy.hostname, AF_INET6); if (host_ent == NULL) { - res->status = http_get_status(503); - print(ERR_STR "Unable to connect to server: Name or service not known" CLR_STR); - sprintf(err_msg, "Unable to connect to server: Name or service not known."); - goto proxy_err; + host_ent = gethostbyname2(conf->rev_proxy.hostname, AF_INET); + if (host_ent == NULL) { + res->status = http_get_status(503); + print(ERR_STR "Unable to connect to server: Name or service not known" CLR_STR); + sprintf(err_msg, "Unable to connect to server: Name or service not known."); + goto proxy_err; + } } struct sockaddr_in6 address = {.sin6_family = AF_INET6, .sin6_port = htons(conf->rev_proxy.port)};