如何更改 esxi 主机 6.7 中的默认端口 80 和 443?

How can i change default port 80 and 443 in esxi host 6.7?

我是 运行 一个免费的 esxi 6.7。

我想通过我的路由器将我的 esxi 公开到互联网。但我想更改默认端口 80 和 443。

我发现许多教程/知识库可用于 esxi 5.0 和 6.0,但其中 none 有效。

在这些教程中,有部分与防火墙和反向代理有关,但无论我做什么,都没有用,主要是当我重新启动防火墙时。

我想它已经解决了,但对于其他人....

如何在 ESXi 6.7 主机上通过 ssh 更改端口视频 -> https://www.youtube.com/watch?v=a7kuwmLuwvU 或在路由器端口中设置从 443 重定向到所需端口(如果可能)。

编辑: 对于他们喜欢阅读的内容:-)

1. enable ssh on esxi host
2. connect via ssh or press alt + f1 on esxi host
3. edit this file by command vi /etc/vmware/rhttpproxy/config.xml
4. find text https by command :/https
<!-- HTTPS port to be used by the reverse proxy -->
<httpsPort>443</httpsPort>
5. change port to eg. 9443 
(press insert before editing and after finished press esc save it by :wq)
6. reboot needed by command reboot
7. after reboot connect to ssh and create new file changedport.xml by command 
vi /etc/vmware/firewall/changedport.xml
8. copy this text to console.
<ConfigRoot>
  <service>
    <id>changedport</id>
    <rule id='0000'>
      <direction>inbound</direction>
      <protocol>tcp</protocol>
      <porttype>dst</porttype>
      <port>9443</port>
    </rule>
    <enabled>true</enabled>
    <required>false</required>
  </service>
</ConfigRoot>
9. save it by :wq
10. refresh firewall rules by command esxcli network firewall refresh

这不是永久性的解决方案。 重启后需要重新添加防火墙规则 并执行命令 esxcli network firewall refresh

感谢您的帮助。

如您所述,这不是永久性的解决方案。

要使其永久化,您需要执行相同的操作,但将其保存在 VIB 文件中,如下所述:

https://www.altaro.com/vmware/how-to-create-persistent-firewall-rules-on-esxi/#comment-18186

按照本指南,我创建了自己的允许端口 444 的自定义 vib

您可以在这里下载:https://multifilemirror.com/hik1l28cf6du/firewall444.vib.html

此 VIB 文件是一个简单的存档文件,因此您可以多次解压它以查看其中的 xml 文件,以验证它只是这个文件并且没有其他恶意附加设置。

只需将 VIB 文件上传到 ESXI 服务器和 运行 'esxcli software vib install' 命令即可使用 SSH 安装它

步骤:

  1. 编辑“/etc/vmware/rhttpproxy/config.xml”(<httpsPort>443</httpsPort><httpsPort>4444</httpsPort>

  2. 运行 命令“/etc/init.d/rhttpproxy 重启”

  3. 创建新文件“/etc/vmware/firewall/changes.xml”

  4. 将此文本复制到文件:

<ConfigRoot>
    <service>
        <id>changedport</id>
        <rule id='0000'>
            <direction>inbound</direction>
            <protocol>tcp</protocol>
            <porttype>dst</porttype>
            <port>4444</port>
        </rule>
        <enabled>true</enabled>
        <required>false</required>
    </service>
</ConfigRoot>
  1. 运行 命令“/sbin/esxcli 网络防火墙刷新”

  2. 复制以上文件到/vmfs/volumes/xxxxxxx-80925220-52bf-b8ac6f41950b/changes.xml

  3. 将以下代码添加到“/etc/rc.local.d/local.sh”以在重启后工作:

/sbin/cp /vmfs/volumes/xxxxxxx-80925220-52bf-b8ac6f41950b/changes.xml/ etc/vmware/firewall/

/sbin/esxcli network firewall refresh

exit 0

完成。