From 9ac1280a122330e7cdae281713039c53a4d5b520 Mon Sep 17 00:00:00 2001 From: AK Date: Sun, 17 Sep 2023 14:06:55 -0400 Subject: [PATCH 01/12] testing + load testing instructions --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index e390a5f..a638399 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,13 @@ There are a few ways you can use this repo to deploy a server that can be use to ### Option 3: Add locations to your existing Nginx config If you already have servers running nginx, you can copy and paste the locations from the [nginx.conf](https://github.com/mixpanel/tracking-proxy/blob/master/nginx.conf) file in this repo and adjust the locations to match your preference. + + +### Testing + +Once you have a running container, you can test it with: +```bash +nginx -t -c +``` + +If you wish to load test your proxy, see **[mp-proxy-load-test](https://github.com/ak--47/mp-proxy-load-test/)** \ No newline at end of file From 9567d23974b692ba6801e61601f423be4e3c315d Mon Sep 17 00:00:00 2001 From: AK Date: Sun, 17 Sep 2023 22:33:13 -0400 Subject: [PATCH 02/12] test heroku --- README.md | 42 ++++++++++++++++++++++++++++++++++++++---- heroku.yml | 6 ++++++ 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 heroku.yml diff --git a/README.md b/README.md index a638399..fe23da9 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,43 @@ An example nginx config that serves as a proxy to Mixpanel's Ingestion API and J There are a few ways you can use this repo to deploy a server that can be use to proxy Mixpanel API requests: one-click deploy to cloud, build a docker image, or copy and paste the nginx settings to your own nginx config file. ### Option 1: One-click Deploy - - [Run on Google Cloud](https://deploy.cloud.run) - - [Deploy to DigitalOcean](https://cloud.digitalocean.com/apps/new?repo=https://github.com/mixpanel/tracking-proxy/tree/master) - + +[![Google Cloud Btn]][Google Cloud Deploy] +[][Digital Ocean Deploy] +[![Heroku Btn]][Heroku Deploy] +[![Azure Btn]][Azure Deploy] +[![Railway Btn]][Railway Deploy] +[![Vercel Btn]][Vercel Deploy] +[![Netlify Btn]][Netlify Deploy] +[![Render Btn]][Render Deploy] + + + +[Google Cloud Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/googlecloud.svg +[Google Cloud Deploy]: https://deploy.cloud.run + +[Digital Ocean Btn]: https://www.deploytodo.com/do-btn-blue.svg +[Digital Ocean Deploy]: https://cloud.digitalocean.com/apps/new?repo=https://github.com/mixpanel/tracking-proxy/tree/master + +[Heroku Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/heroku.svg +[Heroku Deploy]: https://heroku.com/deploy/?template=https://github.com/ak--47/tracking-proxy/tree/one-clicks + + + + ### Option 2: Docker Image Assuming you have Docker installed on your system, you can do the following: @@ -30,4 +64,4 @@ Once you have a running container, you can test it with: nginx -t -c ``` -If you wish to load test your proxy, see **[mp-proxy-load-test](https://github.com/ak--47/mp-proxy-load-test/)** \ No newline at end of file +If you wish to load test your proxy, see **[mp-proxy-load-test](https://github.com/ak--47/mp-proxy-load-test/)** diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000..59a6bd1 --- /dev/null +++ b/heroku.yml @@ -0,0 +1,6 @@ +build: + docker: + web: Dockerfile + +run: + web: nginx -g 'daemon off;' \ No newline at end of file From 6a0c498918ebc83988288ca1b074481260319f38 Mon Sep 17 00:00:00 2001 From: AK Date: Sun, 17 Sep 2023 22:44:07 -0400 Subject: [PATCH 03/12] trying app.json --- README.md | 10 +++++----- app.json | 14 +++++++++++++- heroku.yml | 6 ------ 3 files changed, 18 insertions(+), 12 deletions(-) delete mode 100644 heroku.yml diff --git a/README.md b/README.md index fe23da9..4ce6853 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ There are a few ways you can use this repo to deploy a server that can be use to [Google Cloud Deploy]: https://deploy.cloud.run [Digital Ocean Btn]: https://www.deploytodo.com/do-btn-blue.svg -[Digital Ocean Deploy]: https://cloud.digitalocean.com/apps/new?repo=https://github.com/mixpanel/tracking-proxy/tree/master +[Digital Ocean Deploy]: https://cloud.digitalocean.com/apps/new?repo=https://github.com/ak--47/tracking-proxy/tree/one-clicks [Heroku Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/heroku.svg [Heroku Deploy]: https://heroku.com/deploy/?template=https://github.com/ak--47/tracking-proxy/tree/one-clicks @@ -32,16 +32,16 @@ There are a few ways you can use this repo to deploy a server that can be use to [Azure Deploy]: https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fquickstarts%2Fmicrosoft.web%2Fwebapp-linux-node%2Fazuredeploy.json [Railway Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/railway.svg -[Railway Deploy]: https://railway.app/new/template?template=https://github.com/mixpanel/tracking-proxy +[Railway Deploy]: https://railway.app/new/template?template=https://github.com/ak--47/tracking-proxy/tree/one-clicks [Vercel Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/vercel.svg -[Vercel Deploy]: https://vercel.com/new/clone?repository-url=https://github.com/mixpanel/tracking-proxy +[Vercel Deploy]: https://vercel.com/new/clone?repository-url=https://github.com/ak--47/tracking-proxy/tree/one-clicks [Netlify Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/netlify.svg -[Netlify Deploy]: https://app.netlify.com/start/deploy?repository=https://github.com/mixpanel/tracking-proxy +[Netlify Deploy]: https://app.netlify.com/start/deploy?repository=https://github.com/ak--47/tracking-proxy/tree/one-clicks [Render Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/render.svg -[Render Deploy]: https://render.com/deploy?repo=https://github.com/mixpanel/tracking-proxy --> +[Render Deploy]: https://render.com/deploy?repo=https://github.com/ak--47/tracking-proxy/tree/one-clicks --> ### Option 2: Docker Image Assuming you have Docker installed on your system, you can do the following: diff --git a/app.json b/app.json index d72870b..c7d7f8b 100644 --- a/app.json +++ b/app.json @@ -3,5 +3,17 @@ "options": { "allow-unauthenticated": true, "port": 80 - } + }, + "description": "a mixpanel proxy", + "repository": "https://github.com/ak--47/tracking-proxy/tree/one-clicks", + "env": { + "PORT": { + "description": "Port to bind on", + "value": "80" + } + }, + "stack": "container", + "buildpacks": [ + {"url": "heroku-community/docker"} + ] } diff --git a/heroku.yml b/heroku.yml deleted file mode 100644 index 59a6bd1..0000000 --- a/heroku.yml +++ /dev/null @@ -1,6 +0,0 @@ -build: - docker: - web: Dockerfile - -run: - web: nginx -g 'daemon off;' \ No newline at end of file From 697deaa8e70aa6554d345e6ab60b2a5a68408293 Mon Sep 17 00:00:00 2001 From: AK Date: Sun, 17 Sep 2023 22:48:55 -0400 Subject: [PATCH 04/12] lol. need yml --- heroku.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 heroku.yml diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000..a429a06 --- /dev/null +++ b/heroku.yml @@ -0,0 +1,6 @@ +build: + docker: + web: Dockerfile + +run: + web: nginx -g 'daemon off;' From 7a70c58f0b5b610a9fb6dfe4cfbe75f71433acd7 Mon Sep 17 00:00:00 2001 From: AK Date: Sun, 17 Sep 2023 23:19:43 -0400 Subject: [PATCH 05/12] heroku is out. --- README.md | 14 +++++++++----- app.json | 27 +++++++++------------------ heroku.yml | 6 ------ 3 files changed, 18 insertions(+), 29 deletions(-) delete mode 100644 heroku.yml diff --git a/README.md b/README.md index 4ce6853..7cf648e 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,11 @@ There are a few ways you can use this repo to deploy a server that can be use to [![Google Cloud Btn]][Google Cloud Deploy] [][Digital Ocean Deploy] -[![Heroku Btn]][Heroku Deploy] -[![Azure Btn]][Azure Deploy] -[![Railway Btn]][Railway Deploy] + [![Vercel Btn]][Vercel Deploy] [![Netlify Btn]][Netlify Deploy] +[![Azure Btn]][Azure Deploy] +[![Railway Btn]][Railway Deploy] [![Render Btn]][Render Deploy] @@ -24,18 +24,22 @@ There are a few ways you can use this repo to deploy a server that can be use to [Digital Ocean Btn]: https://www.deploytodo.com/do-btn-blue.svg [Digital Ocean Deploy]: https://cloud.digitalocean.com/apps/new?repo=https://github.com/ak--47/tracking-proxy/tree/one-clicks + [Heroku Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/heroku.svg [Heroku Deploy]: https://heroku.com/deploy/?template=https://github.com/ak--47/tracking-proxy/tree/one-clicks +[Vercel Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/vercel.svg +[Vercel Deploy]: https://vercel.com/new/clone?repository-url=https://github.com/ak--47/tracking-proxy/tree/one-clicks + + -[![Vercel Btn]][Vercel Deploy] +[![Railway Btn]][Railway Deploy] [![Netlify Btn]][Netlify Deploy] [![Azure Btn]][Azure Deploy] -[![Railway Btn]][Railway Deploy] [![Render Btn]][Render Deploy] + + [Google Cloud Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/googlecloud.svg @@ -28,16 +28,14 @@ There are a few ways you can use this repo to deploy a server that can be use to [Heroku Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/heroku.svg [Heroku Deploy]: https://heroku.com/deploy/?template=https://github.com/ak--47/tracking-proxy/tree/one-clicks - -[Vercel Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/vercel.svg -[Vercel Deploy]: https://vercel.com/new/clone?repository-url=https://github.com/ak--47/tracking-proxy/tree/one-clicks +[Railway Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/railway.svg +[Railway Deploy]: https://railway.app/new/template?template=https://github.com/ak--47/tracking-proxy/tree/one-clicks @@ -24,26 +24,22 @@ There are a few ways you can use this repo to deploy a server that can be use to [Digital Ocean Btn]: https://www.deploytodo.com/do-btn-blue.svg [Digital Ocean Deploy]: https://cloud.digitalocean.com/apps/new?repo=https://github.com/ak--47/tracking-proxy/tree/one-clicks - + [Heroku Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/heroku.svg [Heroku Deploy]: https://heroku.com/deploy/?template=https://github.com/ak--47/tracking-proxy/tree/one-clicks [Railway Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/railway.svg -[Railway Deploy]: https://railway.app/new/template?template=https://github.com/ak--47/tracking-proxy/tree/one-clicks - - - -[Netlify Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/netlify.svg -[Netlify Deploy]: https://app.netlify.com/start/deploy?repository=https://github.com/ak--47/tracking-proxy/tree/one-clicks -[Render Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/render.svg -[Render Deploy]: https://render.com/deploy?repo=https://github.com/ak--47/tracking-proxy/tree/one-clicks --> ### Option 2: Docker Image Assuming you have Docker installed on your system, you can do the following: From 564227b6d3429b290069ea2c4642d31911c013b7 Mon Sep 17 00:00:00 2001 From: AK Date: Sun, 17 Sep 2023 23:47:04 -0400 Subject: [PATCH 08/12] render deploy config --- render.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 render.yaml diff --git a/render.yaml b/render.yaml new file mode 100644 index 0000000..b74aa95 --- /dev/null +++ b/render.yaml @@ -0,0 +1,9 @@ +services: + - type: docker + name: nginx-proxy + env: docker + plan: starter + dockerfilePath: './Dockerfile' + envVars: + - key: PORT + value: '80' From b89f41f8b306c06d3ff81bd1aee5fca9635ff7d9 Mon Sep 17 00:00:00 2001 From: AK Date: Sun, 17 Sep 2023 23:48:39 -0400 Subject: [PATCH 09/12] fix render --- render.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/render.yaml b/render.yaml index b74aa95..3901c5e 100644 --- a/render.yaml +++ b/render.yaml @@ -1,5 +1,5 @@ services: - - type: docker + - type: web name: nginx-proxy env: docker plan: starter From c70dd202c2bb4ec676ac6d2afe5f442f8b6c240d Mon Sep 17 00:00:00 2001 From: AK Date: Mon, 18 Sep 2023 00:27:14 -0400 Subject: [PATCH 10/12] cleanup --- README.md | 54 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 4675f59..cffbfaa 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,31 @@ # Nginx Proxy for Mixpanel An example nginx config that serves as a proxy to Mixpanel's Ingestion API and JavaScript library endpoints. To learn more, visit our [docs on Tracking via Proxy](https://docs.mixpanel.com/docs/tracking/how-tos/tracking-via-proxy). + ## Installation -There are a few ways you can use this repo to deploy a server that can be use to proxy Mixpanel API requests: one-click deploy to cloud, build a docker image, or copy and paste the nginx settings to your own nginx config file. +There are a few ways you can use this repo to deploy a server that can be use to proxy Mixpanel API requests: + +1. **one-click deploy** to your cloud provider +2. **build a docker image** and run it on your own servers +3. **copy and paste** the nginx settings to your existing nginx config file -### Option 1: One-click Deploy +### Option 1: One-Click Deploy +click on a button below to deploy to your favorite cloud provider: [![Google Cloud Btn]][Google Cloud Deploy] [][Digital Ocean Deploy] [![Railway Btn]][Railway Deploy] [![Render Btn]][Render Deploy] -[![Azure Btn]][Azure Deploy] - - - [Google Cloud Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/googlecloud.svg [Google Cloud Deploy]: https://deploy.cloud.run [Digital Ocean Btn]: https://www.deploytodo.com/do-btn-blue.svg [Digital Ocean Deploy]: https://cloud.digitalocean.com/apps/new?repo=https://github.com/ak--47/tracking-proxy/tree/one-clicks - -[Heroku Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/heroku.svg -[Heroku Deploy]: https://heroku.com/deploy/?template=https://github.com/ak--47/tracking-proxy/tree/one-clicks - [Railway Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/railway.svg [Railway Deploy]: https://railway.app/template/_RaWSW @@ -35,8 +33,15 @@ There are a few ways you can use this repo to deploy a server that can be use to [Render Deploy]: https://render.com/deploy?repo=https://github.com/ak--47/tracking-proxy/tree/one-clicks - + + + +[Heroku Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/heroku.svg +[Heroku Deploy]: https://heroku.com/deploy/?template=https://github.com/ak--47/tracking-proxy/tree/one-clicks + + +[Azure Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/azure.svg +[Azure Deploy]: https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FYOUR_GITHUB_USERNAME%2FYOUR_REPO_NAME%2FYOUR_BRANCH_NAME%2Fpath%2Fto%2Fazuredeploy.json @@ -44,16 +49,31 @@ There are a few ways you can use this repo to deploy a server that can be use to ### Option 2: Docker Image Assuming you have Docker installed on your system, you can do the following: - 1. Clone the repo - 2. Build the Docker image: `docker build -t mixpanel-proxy .` - 3. Run a container using the image: `docker run --name my-tracking-proxy -d -p 8080:80 mixpanel-proxy` - 4. Visit `http://localhost:8080` + 1. Clone the repo + `git clone https://github.com/mixpanel/tracking-proxy` + 2. Build the Docker image: + `docker build -t mixpanel-proxy .` + 3. Run a container using the image: + `docker run --name my-tracking-proxy -d -p 8080:80 mixpanel-proxy` + 4. Visit + `http://localhost:8080` + +You should see: + +```json +{ + "error": "Welcome. Get started with our API by visiting https://developer.mixpanel.com/" +} +``` +This is same response you would get from visiting https://api.mixpanel.com/, which means your proxy is working as expected.. - For production, you would deploy this docker image to whatever servers you run your production services on. +For production, you would deploy this docker image to whatever servers you run your production services on. ### Option 3: Add locations to your existing Nginx config If you already have servers running nginx, you can copy and paste the locations from the [nginx.conf](https://github.com/mixpanel/tracking-proxy/blob/master/nginx.conf) file in this repo and adjust the locations to match your preference. +### EU Residency +This proxy server resolves requests to `api.mixpanel.com`, which points to Mixpanel's primary data centers in the United States. If you are using Mixpanel's **[EU Data Residency](https://docs.mixpanel.com/docs/other-bits/privacy-and-security/eu-residency)**, you will need to change the [nginx.config](https://github.com/mixpanel/tracking-proxy/blob/master/nginx.conf#L34) from `api.mixpanel.com` to `api-eu.mixpanel.com` ### Testing From 9659c24f1c4a1ebbed13fce6886004dec278c534 Mon Sep 17 00:00:00 2001 From: AK Date: Mon, 18 Sep 2023 00:29:42 -0400 Subject: [PATCH 11/12] final proofing. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cffbfaa..52ab553 100644 --- a/README.md +++ b/README.md @@ -62,10 +62,10 @@ You should see: ```json { - "error": "Welcome. Get started with our API by visiting https://developer.mixpanel.com/" + "error": "Welcome. Get started with our API by visiting https://developer.mixpanel.com/" } ``` -This is same response you would get from visiting https://api.mixpanel.com/, which means your proxy is working as expected.. +This is same response you would get from visiting https://api.mixpanel.com/ (which means your proxy is working as expected). For production, you would deploy this docker image to whatever servers you run your production services on. @@ -82,4 +82,4 @@ Once you have a running container, you can test it with: nginx -t -c ``` -If you wish to load test your proxy, see **[mp-proxy-load-test](https://github.com/ak--47/mp-proxy-load-test/)** +If you wish to load test your proxy, see **[mp-proxy-load-test](https://github.com/ak--47/mp-proxy-load-test/)** for a load testing script with artillery. From b9bd6dce95b9aa71b5449ab9d6177b02e1ce7b32 Mon Sep 17 00:00:00 2001 From: AK Date: Mon, 18 Sep 2023 00:38:23 -0400 Subject: [PATCH 12/12] update URLs --- README.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 52ab553..224e5af 100644 --- a/README.md +++ b/README.md @@ -24,20 +24,20 @@ click on a button below to deploy to your favorite cloud provider: [Google Cloud Deploy]: https://deploy.cloud.run [Digital Ocean Btn]: https://www.deploytodo.com/do-btn-blue.svg -[Digital Ocean Deploy]: https://cloud.digitalocean.com/apps/new?repo=https://github.com/ak--47/tracking-proxy/tree/one-clicks +[Digital Ocean Deploy]: https://cloud.digitalocean.com/apps/new?repo=https://github.com/mixpanel/tracking-proxy [Railway Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/railway.svg [Railway Deploy]: https://railway.app/template/_RaWSW [Render Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/render.svg -[Render Deploy]: https://render.com/deploy?repo=https://github.com/ak--47/tracking-proxy/tree/one-clicks +[Render Deploy]: https://render.com/deploy?repo=https://github.com/mixpanel/tracking-proxy - + [Heroku Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/heroku.svg -[Heroku Deploy]: https://heroku.com/deploy/?template=https://github.com/ak--47/tracking-proxy/tree/one-clicks +[Heroku Deploy]: https://heroku.com/deploy/?template=https://github.com/mixpanel/tracking-proxy [Azure Btn]: https://binbashbanana.github.io/deploy-buttons/buttons/remade/azure.svg @@ -66,6 +66,12 @@ You should see: } ``` This is same response you would get from visiting https://api.mixpanel.com/ (which means your proxy is working as expected). + +You can also verify the nginx config on the command line: + +```bash +nginx -t -c /etc/nginx/nginx.conf +``` For production, you would deploy this docker image to whatever servers you run your production services on. @@ -75,11 +81,6 @@ For production, you would deploy this docker image to whatever servers you run y ### EU Residency This proxy server resolves requests to `api.mixpanel.com`, which points to Mixpanel's primary data centers in the United States. If you are using Mixpanel's **[EU Data Residency](https://docs.mixpanel.com/docs/other-bits/privacy-and-security/eu-residency)**, you will need to change the [nginx.config](https://github.com/mixpanel/tracking-proxy/blob/master/nginx.conf#L34) from `api.mixpanel.com` to `api-eu.mixpanel.com` -### Testing - -Once you have a running container, you can test it with: -```bash -nginx -t -c -``` +### Load Testing If you wish to load test your proxy, see **[mp-proxy-load-test](https://github.com/ak--47/mp-proxy-load-test/)** for a load testing script with artillery.