add proxy to pandorabox tileserver

master
Thomas Rudin 2018-09-06 09:46:03 +02:00
parent 54fed1c9a6
commit 24ccd3cb40
2 changed files with 54 additions and 0 deletions

24
package.json Normal file
View File

@ -0,0 +1,24 @@
{
"name": "minetest-tile-server",
"version": "1.0.0",
"description": "Minetest tileserver =======",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/thomasrudin-mt/minetest-tile-server.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/thomasrudin-mt/minetest-tile-server/issues"
},
"homepage": "https://github.com/thomasrudin-mt/minetest-tile-server#readme",
"dependencies": {
"connect": "^3.6.6",
"http-proxy": "^1.17.0",
"serve-static": "^1.13.2"
}
}

30
proxy.js Normal file
View File

@ -0,0 +1,30 @@
var httpProxy = require('http-proxy'),
http = require("http"),
serveStatic = require('serve-static'),
connect = require('connect');
var proxy = httpProxy.createProxy({
target: "https://pandorabox.io/map",
secure: false
});
var app = connect()
.use("/", function(req, res, next){
if (req.url.substring(0,3) == "/js"){
console.log("Local: " + req.url);
next();
return;
}
console.log("Remote: " + req.url);
proxy.web(req, res);
})
.use(serveStatic("src/main/resources/public"));
var server = http.createServer(app);
server.listen(8080);
console.log("Listening on http://127.0.0.1:8080");