mixpanel / tracking-proxy

One-click configuration to proxy tracking requests to Mixpanel's API
63 stars 117 forks source link

Error with the nginx proxy settings #1

Closed pragyanatvade closed 3 years ago

pragyanatvade commented 3 years ago

While trying to use these nginx settings we are getting following error.

<?xml version='1.0' encoding='UTF-8'?><Error><Code>InvalidArgument</Code><Message>Invalid argument.</Message><Details>POST object expects Content-Type multipart/form-data</Details></Error>

I tried adding Content-Type: multipart/form-data

But that starts throwing following error:

Bad content type.  Please use multipart.

Any way to solve this problem?

SirensOfTitan commented 3 years ago

Change proxy_pass https://api.mixpanel.com; to proxy_pass https://api.mixpanel.com/;, there's a trailing slash missing. Works for me after that.

jbwyme commented 3 years ago

what version of nginx are you folks using out of curiosity?

SirensOfTitan commented 3 years ago

@jbwyme: nginx -V:

nginx version: nginx/1.19.6
built by gcc 10.2.1 20201203 (Alpine 10.2.1_pre1) 
built with OpenSSL 1.1.1i  8 Dec 2020
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --modules-path=/etc/nginx/modules --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-compat --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_geoip_module --with-http_gzip_static_module --with-http_sub_module --with-http_v2_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-stream_ssl_preread_module --with-threads --with-http_secure_link_module --with-http_gunzip_module --with-file-aio --without-mail_pop3_module --without-mail_smtp_module --without-mail_imap_module --without-http_uwsgi_module --without-http_scgi_module --with-cc-opt='-g -Og -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wno-deprecated-declarations -fno-strict-aliasing -D_FORTIFY_SOURCE=2 --param=ssp-buffer-size=4 -DTCP_FASTOPEN=23 -fPIC -I/root/.hunter/_Base/2c5c6fc/c6aa85a/92161a9/Install/include -Wno-cast-function-type -m64 -mtune=native' --with-ld-opt='-fPIE -fPIC -pie -Wl,-z,relro -Wl,-z,now -L/root/.hunter/_Base/2c5c6fc/c6aa85a/92161a9/Install/lib' --user=www-data --group=www-data --add-module=/tmp/build/ngx_devel_kit-0.3.1 --add-module=/tmp/build/set-misc-nginx-module-0.32 --add-module=/tmp/build/headers-more-nginx-module-0.33 --add-module=/tmp/build/ngx_http_substitutions_filter_module-bc58cb11844bc42735bbaef7085ea86ace46d05b --add-module=/tmp/build/lua-nginx-module-138c1b96423aa26defe00fe64dd5760ef17e5ad8 --add-module=/tmp/build/stream-lua-nginx-module-0.0.9 --add-module=/tmp/build/lua-upstream-nginx-module-0.07 --add-module=/tmp/build/nginx_ajp_module-bf6cd93f2098b59260de8d494f0f4b1f11a84627 --add-dynamic-module=/tmp/build/nginx-http-auth-digest-cd8641886c873cf543255aeda20d23e4cd603d05 --add-dynamic-module=/tmp/build/nginx-influxdb-module-5b09391cb7b9a889687c0aa67964c06a2d933e8b --add-dynamic-module=/tmp/build/nginx-opentracing-0.10.0/opentracing --add-dynamic-module=/tmp/build/ModSecurity-nginx-22e53aba4e3ae8c7d59a3672d6727e49246afe96 --add-dynamic-module=/tmp/build/ngx_http_geoip2_module-3.3 --add-dynamic-module=/tmp/build/ngx_brotli
jbwyme commented 3 years ago

Can you tell me whether the /decide endpoint works without the trailing slash? Just trying to make sure I make the correct fix.

SirensOfTitan commented 3 years ago

Hey @jbwyme: /decide does indeed work without the trailing slash. Here's my working configuration:

      location /mxpnl/ {
        proxy_set_header Host api.mixpanel.com;
        proxy_set_header X-Real-IP $http_x_forwarded_for;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_pass https://api.mixpanel.com/;
      }

      location /mxpnl/decide {
        proxy_set_header Host decide.mixpanel.com;
        proxy_set_header X-Real-IP $http_x_forwarded_for;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_pass https://decide.mixpanel.com/decide;
      }
pragyanatvade commented 3 years ago

Closing this issue as @SirensOfTitan configuration worked for us as well. Thanks 😊

carchrae commented 3 years ago

this should not be closed until the PR is merged. @jbwyme are you still working on this/for mixpanel?

please fix.

jbwyme commented 3 years ago

yes sorry just merged the PR!