1

My goal is to setup http/https proxy for redirectinspector.

Google App Engine has some geo zones so I'm using this. I created server used nodejs and deployed used standard environment. As I saw in stackdriver app engine does not give access. It works well on localhost, but if we deploy it fails because never executes. Before creating own server(without extra libs), I deployed two other proxy servers (anyproxy and http-proxy) I got the same response. It seems like bug.

below deployed code

'use strict';
const http = require('http');
const net = require('net');
const url = require('url');

const proxyServer = http.createServer((clientReq, clientRes) => {
  console.log('on Request');
  console.log(clientReq.url);
  if (clientReq.url === '/') {
    clientRes.end('Use as proxy, no direct invocation')
  } else {
    const proxy = http.request(
      clientReq.url,
      {
        headers: clientReq.headers,
        method: clientReq.method
      }
    );

    proxy.on('response', (serverRes) => {
      clientRes.writeHead(
        serverRes.statusCode,
        serverRes.headers
      );
      serverRes.pipe(clientRes, {end: true});
    });

    clientReq.pipe(proxy, {end: true})
  }
});

proxyServer.on('connect', (clientRequest, clientSocket) => {
  console.log('on Connect');
  const srvUrl = url.parse(`https://${clientRequest.url}`);
  console.log(clientRequest.url, srvUrl);
  const srvSocket = net.connect(srvUrl.port, srvUrl.hostname, () => {
    clientSocket.write('HTTP/' + clientRequest.httpVersion + ' 200 OK\r\n' +
      'Connection: close\r\n' + '\r\n', 'UTF-8', () => {
      srvSocket.pipe(clientSocket);
      clientSocket.pipe(srvSocket);
    })

  });

  srvSocket.on('error', e => {
    console.log('srvSocket.on error: ', e);
  });

  clientSocket.on('error', e => {
    console.log('clientSocket.on error: ', e);
  });
});


const listener = proxyServer.listen(process.env.PORT || 3000, (err) => {
  if (err) {
    console.log('error starting server: ', err);
  }
});

Looks like proxyServer.on('connect',... never executed. Like http proxy requests are not delivered to app (logs are empty, filtered on edge reverse proxy at google cloud)

Does someone know the solution create proxy on app engine? (doesn't matter which language use)

0

I know that zeit.co for example not allowing to host http proxy. Their reverse proxy will just drop all requests, not passing them to hosted function. Probably google has the same policy.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.