Reverse proxy IPv6 and IPv4
This commit is contained in:
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
CFLAGS=-std=c11 -Wall
|
CFLAGS=-std=gnu11 -Wall
|
||||||
INCLUDE=-lssl -lcrypto -lmagic -lz -lmaxminddb -lbrotlienc
|
INCLUDE=-lssl -lcrypto -lmagic -lz -lmaxminddb -lbrotlienc
|
||||||
LIBS=src/lib/*.c
|
LIBS=src/lib/*.c
|
||||||
|
|
||||||
|
@ -192,12 +192,15 @@ int rev_proxy_init(http_req *req, http_res *res, host_config *conf, sock *client
|
|||||||
goto proxy_err;
|
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) {
|
if (host_ent == NULL) {
|
||||||
res->status = http_get_status(503);
|
host_ent = gethostbyname2(conf->rev_proxy.hostname, AF_INET);
|
||||||
print(ERR_STR "Unable to connect to server: Name or service not known" CLR_STR);
|
if (host_ent == NULL) {
|
||||||
sprintf(err_msg, "Unable to connect to server: Name or service not known.");
|
res->status = http_get_status(503);
|
||||||
goto proxy_err;
|
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)};
|
struct sockaddr_in6 address = {.sin6_family = AF_INET6, .sin6_port = htons(conf->rev_proxy.port)};
|
||||||
|
Reference in New Issue
Block a user