diff --git a/README b/README index fb279fc..2710cdb 100644 --- a/README +++ b/README @@ -42,6 +42,7 @@ Command line options: -na Disable autogenerated caps.txt -nm Disable shared memory use (for debugging) -nr Disable root user checking (for debugging) + -np Disable HAproxy proxy protocol -d Debug to syslog (not for production use) -v Display version number and build date diff --git a/gophernicus.c b/gophernicus.c index 06dadb3..da78bc8 100644 --- a/gophernicus.c +++ b/gophernicus.c @@ -451,6 +451,7 @@ void init_state(state *st) st->opt_caps = TRUE; st->opt_shm = TRUE; st->opt_root = TRUE; + st->opt_proxy = TRUE; st->debug = FALSE; /* Load default suffix -> filetype mappings */ @@ -573,7 +574,7 @@ get_selector: /* Handle HAproxy/Stunnel proxy protocol v1 */ #ifdef ENABLE_HAPROXY1 - if (sstrncmp(selector, "PROXY TCP") == MATCH) { + if (sstrncmp(selector, "PROXY TCP") == MATCH && st.opt_proxy) { if (st.debug) syslog(LOG_INFO, "got proxy protocol header \"%s\"", selector); sscanf(selector, "PROXY TCP%d %s %s %d %d", diff --git a/gophernicus.h b/gophernicus.h index b075f7f..d8a40ed 100644 --- a/gophernicus.h +++ b/gophernicus.h @@ -349,6 +349,7 @@ typedef struct { char opt_caps; char opt_shm; char opt_root; + char opt_proxy; char debug; } state; diff --git a/options.c b/options.c index fe9e12a..fa1d8e7 100644 --- a/options.c +++ b/options.c @@ -142,6 +142,7 @@ void parse_args(state *st, int argc, char *argv[]) if (*optarg == 'a') { st->opt_caps = FALSE; break; } if (*optarg == 'm') { st->opt_shm = FALSE; break; } if (*optarg == 'r') { st->opt_root = FALSE; break; } + if (*optarg == 'p') { st->opt_proxy = FALSE; break; } break; case 'd': st->debug = TRUE; break;