diff --git a/src/connection.c b/src/connection.c index 2363e0b..8805962 100644 --- a/src/connection.c +++ b/src/connection.c @@ -385,7 +385,9 @@ void connection_connect_to_upstream(connection_t *client, const char *data, size } if (old_host_header_start) { - if (route->upstream_port == 80 || route->upstream_port == 443) { + int is_default_port = (route->use_ssl && route->upstream_port == 443) || + (!route->use_ssl && route->upstream_port == 80); + if (is_default_port) { snprintf(new_host_header, sizeof(new_host_header), "Host: %s\r\n", route->upstream_host); } else { snprintf(new_host_header, sizeof(new_host_header), "Host: %s:%d\r\n", route->upstream_host, route->upstream_port);