How to open an internal port in Openshift 3 Online?

假如想象 提交于 2019-12-13 02:47:23

问题


Say if I want to open two ports, one for the public at 8080, and another one to process some public request but was forwarded by the 8080 port like such:

const http = require('http');
const publicServer = http.createServer(...).listen(8080);
const privateServer = http.createServer(...).listen(9999);
publicServer.on('connect', (req, cltSocket, head) => {
  ...
  if (...) {
    // let srvSocket = net.connect('9999', 'localhost', () => {
    let srvSocket = net.connect('9999', '127.0.0.1', () => {
      cltSocket.write('\r\n\r\n');
      srvSocket.write(head);
      srvSocket.pipe(cltSocket);
      cltSocket.pipe(srvSocket);
    });
  }
});

Is there some type of settings I can use to allow this? Currently it seems Openshift doesn't allow this setup. It is possible that it doesn't honor 127.0.0.1 or localhost and therefore not forwarding the request to the correct pod...


回答1:


There should be no reason why you cant connect to port 9999 via localhost or 127.0.0.1 from any process in any container of the same pod.

Have you tried using oc rsh to access the running container and gone:

curl localhost:9999

to verify that your code is actually listening properly on port 9999?



来源:https://stackoverflow.com/questions/49868635/how-to-open-an-internal-port-in-openshift-3-online

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!