Html 如何允许用户访问某个url而不需要端口
我觉得这是一个基本的问题,但我很难在我的研究中找到任何具体的东西。这一定是一个常见的问题,我不知道谷歌该怎么做 我正在运行一个空隙Kubernetes集群,其中包含一组服务,所有这些服务上都有UI。我的服务使用NodePort公开。我可以通过执行ip addr:NodePort导航到ui。我使用dnsmasq设置了DNS,因此我可以访问example.domain.com:NodePort上的URL 我想隐藏url的节点端口部分,以便用户/客户端可以访问example.domain.com/appname上的应用程序 我正在运行一个ApacheWebServer来服务一些文件,我已经实现了一系列重定向,例如 重定向永久/appname 当通过firefox浏览器(例如example.domain.com/appname)访问UI时,它的工作方式非常好。这确实会改变用户地址栏中的URL,但我可以接受。问题是,有些客户端不会自动重定向到,而只是显示301状态代码 谁能给我指一下正确的方向吗Html 如何允许用户访问某个url而不需要端口,html,apache,kubernetes,dns,dnsmasq,Html,Apache,Kubernetes,Dns,Dnsmasq,我觉得这是一个基本的问题,但我很难在我的研究中找到任何具体的东西。这一定是一个常见的问题,我不知道谷歌该怎么做 我正在运行一个空隙Kubernetes集群,其中包含一组服务,所有这些服务上都有UI。我的服务使用NodePort公开。我可以通过执行ip addr:NodePort导航到ui。我使用dnsmasq设置了DNS,因此我可以访问example.domain.com:NodePort上的URL 我想隐藏url的节点端口部分,以便用户/客户端可以访问example.domain.com/ap
谢谢您必须将HTTP流量从标准端口80重定向到您的节点端口 比如说
sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 30000
使用apache或nginx,您可以只使用隐藏内部端口的虚拟服务器。我认为您不需要进行任何重定向,您只需要从虚拟服务器向外部客户端提供一个url:80 WHO后端,上游节点是您的内部节点,带有节点端口 您可以找到nginx、ha-proxy和其他更简单、更好的示例 下面是一个apache示例:
<VirtualHost *:80>
ProxyRequests off
ServerName domain.com
<Proxy balancer://mycluster>
# WebHead1
BalancerMember http://node:NodePort
# WebHead2
BalancerMember http://node:NodePort
# Security "technically we aren't blocking
# anyone but this is the place to make
# those changes.
Require all granted
# In this example all requests are allowed.
# Load Balancer Settings
# We will be configuring a simple Round
# Robin style load balancer. This means
# that all webheads take an equal share of
# of the load.
ProxySet lbmethod=byrequests
</Proxy>
# balancer-manager
# This tool is built into the mod_proxy_balancer
# module and will allow you to do some simple
# modifications to the balanced group via a gui
# web interface.
<Location /balancer-manager>
SetHandler balancer-manager
# I recommend locking this one down to your
# your office
Require host example.org
</Location>
# Point of Balance
# This setting will allow to explicitly name the
# the location in the site that we want to be
# balanced, in this example we will balance "/"
# or everything in the site.
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/
</VirtualHost>
在看到Ijaz的答案后,我能够稍微改进我的谷歌搜索,并得出以下结论: /etc/主持人
192.168.100.1 example.domain.com gitlab.domain.com example
192.168.100.1 example.domain.com example
但是,当我导航到example.domain.com/gitlab时,它会附加正确的url,例如gitlab的登录页是/users/sign_in,example.domain.com/users/sign_in,但我的浏览器显示为Not Found。在服务器上找不到请求URL/users/sign_in
我想不出正确的配置。如果有人有任何进一步的想法来解决这个问题,请告诉我。我恐怕无法得到你的答案,但它确实让我找到了正确的方向,所以谢谢你。我将单独发布我的答案-如果你能看一下,我仍然有一个疑问。上面的例子只是一个示例,它确实有效,没有经过测试,你当然需要更改它
192.168.100.1 example.domain.com example
<VirtualHost *:80>
ServerName example.domain.com
ProxyPass /gitlab http://example.domain.com:30100/
ProxyReversePass /gitlab http://example.domain.com:30100/
ProxyPass /jira http://example.domain.com:30111/
ProxyReversePass /jira http://example.domain.com:30111/
</VirtualHost>