如何在Openshift 3 Online中打开内部端口? [英] How to open an internal port in Openshift 3 Online?

查看:219
本文介绍了如何在Openshift 3 Online中打开内部端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我要打开两个端口,一个在8080供公众使用,另一个用于处理一些公共请求,但由8080端口转发,如下所示:

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);
    });
  }
});

是否可以使用某些类型的设置?目前,似乎Openshift不允许此设置.可能不接受127.0.0.1localhost,因此没有将请求转发到正确的Pod ...

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...

推荐答案

没有理由不能从同一容器的任何容器中的任何进程通过localhost127.0.0.1连接到端口9999.

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.

您是否尝试过使用oc rsh访问正在运行的容器并消失了:

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

curl localhost:9999

要验证您的代码是否确实在端口9999上正确侦听?

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

这篇关于如何在Openshift 3 Online中打开内部端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆