DataDog / browser-sdk

Datadog Browser SDK
Apache License 2.0
305 stars 135 forks source link

🙏 Need help to setup RUM datadog proxy with NGINX #3111

Open vedansh-kapoor opened 1 week ago

vedansh-kapoor commented 1 week ago

I am trying to set up proxy for datadog rum events as a lot of them get blocked by ad-blockers and browsers like brave

I have gone through the documentation at https://docs.datadoghq.com/real_user_monitoring/guide/proxy-rum-data/?tab=npm#proxy-setup and still failing to set up the proxy in my nginx.conf below -

location /rum-logs/v2/ {
    if ($request_method = OPTIONS) {
        add_header Access-Control-Allow-Origin "*";
        add_header Access-Control-Allow-Methods "GET, PUT, POST, DELETE, OPTIONS";
        add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With";
        add_header Access-Control-Allow-Credentials "true";
        add_header Content-Length 0;
        add_header Content-Type text/plain;
        return 204;
     }
     rewrite ^/rum-logs/(.*) /$1  break;
     proxy_redirect off;
     proxy_ssl_session_reuse off;
     proxy_ssl_server_name on;
     proxy_set_header Host datadoghq.com;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto $scheme;
     set $datadog_url "https://browser-intake-datadoghq.com";
     set $proxy_pass_url "${datadog_url}${arg_ddforward}";
     proxy_pass $proxy_pass_url;
   }

When I try to print the ${arg_ddforward} in my nginx logs, I can see the URL, but $proxy_pass_url is always an empty string

Can someone help with this? Is some decoding needed? Or any other way to achieve this?

amortemousque commented 1 week ago

Hello @vedansh-kapoor,

The best way for us to help you on that front is to reach out to the support.

vedansh-kapoor commented 1 week ago

@amortemousque Support was not very helpful, redirected me to this https://github.com/DataDog/browser-sdk/issues/2471#issuecomment-1857997007 , which did not work in my case. Still getting HTTP 426 errors