Skip to content

Instantly share code, notes, and snippets.

@reu
Created April 18, 2018 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reu/6168f8f37111691d50a8a25377206e35 to your computer and use it in GitHub Desktop.
Save reu/6168f8f37111691d50a8a25377206e35 to your computer and use it in GitHub Desktop.
const http = require("http");
const path = require("path");
const target = process.env.TARGET; // ex: google.com
const port = process.env.PORT || 80;
http
.createServer(({ url, headers }, res) => {
const protocol = headers["x-forwarded-proto"] || "http";
res.writeHead(308, { Location: `${protocol}://${path.join(target, url)}` });
res.end();
})
.listen(port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment