My understanding so far is that an proxy server is ‘just a web server’, but I haven’t been able to receive proxying requests. My purpose is to set up a proxy server that I can control so that I can debug a proxy authentication issue for a different project. Please advise. Thanks.
I have this so far:
var http = require('http');
http.createServer(function(request, response) {
var host = request.headers['host'];
console.log(`port: ${process.env.PORT}, host: ${host}`);
request.addListener('data', function(chunk) {
console.log(chunk.toString());
});
request.addListener('end', function() {
response.statusCode=407;
response.statusMessage='Auth please.';
response.end();
});
}).listen(process.env.PORT);
I can do curl http://proxy-project
and I see my logging messages and am getting back a 407 response.
But curl with proxy:
curl -v -x http://proxy-project:80 http://target-url
does not produce logging messages and returns this response
* Rebuilt URL to: http://target-url/
* Trying 34.192.211.247...
* TCP_NODELAY set
* Connected to proxy-project (34.192.211.247) port 80 (#0)
> GET http://target-url/ HTTP/1.1
> Host: target-url
> User-Agent: curl/7.54.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 404 Not Found
< Date: Fri, 22 Dec 2017 06:30:15 GMT
< Transfer-Encoding: chunked
< Connection: keep-alive
< x-powered-by: Express
<
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>👻 Project Not Found</title>
<meta name="viewport" content="initial-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="https://gomix.com/themes/sugar.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js"></script>
<script src="https://gomix.com/error-page.js"></script>
</head>
<body class="error-page ghost-border">
<div class="container">
<h1>
Project Not Found
</h1>
<h2>
Maybe a typo? Or maybe it's been renamed?
</h2>
<div class="actions">
<a href="https://gomix.com">
<div class="gomix-logo bird">
</div>
</a>
</div>
</div>
<canvas id="stars"></canvas>
</body>
</html>
* Connection #0 to host proxy-project left intact