Reverse proxy IPv6 and IPv4

This commit is contained in:
2021-09-12 19:25:57 +02:00
parent 52ea670d36
commit 433cc7861f
2 changed files with 9 additions and 6 deletions

View File

@ -1,5 +1,5 @@
CFLAGS=-std=c11 -Wall
CFLAGS=-std=gnu11 -Wall
INCLUDE=-lssl -lcrypto -lmagic -lz -lmaxminddb -lbrotlienc
LIBS=src/lib/*.c

View File

@ -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)};