Help needed with Step 3: Implementing the Simplest Proxy Server
See original GitHub issueHey there,
I tried to follow your tutorial on https://www.freecodecamp.org/news/save-your-analytics-from-content-blockers-7ee08c6ec7ee/
And i managed to get things running but i’m stuck at Step 3: Implementing the Simplest Proxy Server
When i browse to http://my-ip/index.html
I get:
Proxied: www.google-analytics.com/r/collect?v=1&_v=j80&a=1503182168&t=pageview&_s=1&dl=http%3A%2F%2Fipremoved%2F&ul=en-us&de=UTF-8&dt=Google%20Analytics%20Test%20Proxy&sd=24-bit&sr=1920x1080&vp=1034x898&je=0&_u=AACAAEAB~&jid=1401297639&gjid=114978947&cid=88200760.1581435787&tid=UA-removed-1&_gid=1603874559.1581435787&_r=1&z=2065047711&uip=maskedip
Proxied: www.google-analytics.com/analytics.js
So it seems to be running.
Problem i get stuck is this: Gathering all the files in the example together (see GitHub), we should end up with the following JavaScript server code:
var express = require("express"),
proxy = require("express-http-proxy"), app = express();
app.use(express.static(__dirname)); // serve static files from cwd
function getIpFromReq (req) { // get the client's IP address
var bareIP = ":" + ((req.connection.socket && req.connection.socket.remoteAddress)
|| req.headers["x-forwarded-for"] || req.connection.remoteAddress || "");
return (bareIP.match(/:([^:]+)$/) || [])[1] || "127.0.0.1";
}
// proxying requests from /analytics to www.google-analytics.com.
app.use("/analytics", proxy("www.google-analytics.com", {
proxyReqPathResolver: function (req) {
return req.url + (req.url.indexOf("?") === -1 ? "?" : "&")
+ "uip=" + encodeURIComponent(getIpFromReq(req));
}
}));
app.listen(1280);
console.log("Web application ready on http://localhost:1280");
Were should i place this code or what should i do with this code?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How To Setup and Configure a Proxy Server – Squid Proxy
This article covers proxy server installtion, configuration and basic proxy authentication using detailed steps. You will learn how to setup ...
Read more >Assignment 1: Proxy Server
Step 1: Forward HTTP requests and responses without caching. First, implement a simple TCP server (on localhost:8888 ) that can receive HTTP ...
Read more >How to Set Up a Proxy in Windows 10 - Dummies.com
Set up a proxy manually · Open Settings. · Click Network & Internet. · Click Proxy. · In the Manual Proxy Setup section,...
Read more >Connecting through Proxy Servers in Core Java - Baeldung
Learn how to connect to proxy servers in Java using system properties or the more flexible Proxy class.
Read more >How to Create Your Own Online Proxy Server in Minutes
How to Create Your Own Online Proxy Server in Minutes · 1. Download and Install PHP-Proxy · 2. Ready for Use · 3....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for the explanation, i will study this and go from there, probably with some trial and error i will figure it out.
For now i will close this as it’s no a real issue.
Thanks again!
Great that you’ve found the solution!
Conceptually, the container (application) in this repo is designed to handle http requests, and all the SSL magic should happen before that, in your case within the Apache proxy.