问题描述
有没有办法我可以从url隐藏端口并使用cname(别名)代替:.
Is there a way i can hide the port from url and use cname (alias) instead of :.
例如如果我的网址是 http://myserver.com:40089/webapps/index.jsp 我可以使用吗 http://mycname/webapps/index.jsp
For e.g. If my url is http://myserver.com:40089/webapps/index.jspIs its possible for me to usehttp://mycname/webapps/index.jsp
我要说的原因是,我可以在名为myserver.com的框内移动,说myserver1.com.我不希望客户端在我移动时总是更改此url.相反,我的客户端应该不知道该服务在何处以及在哪个端口上运行.
Reason i am telling is, i can move around the box called myserver.com to say myserver1.com. I dont want client to always change this url whenever i am moving. Instead my client should be unaware of where the service is running and on which port.
有可能吗?我正在使用码头作为我的网络服务器.
Is it possible? I am using jetty as my webserver.
谢谢.
推荐答案
使用DNS CNAME,您只能从一个主机名指向另一个主机名.端口号是完全不同的事情.
With DNS CNAME you can only point from one hostname to another. Port numbers are a totally different piece of cake.
上述情况存在几个问题:
There are several problems with the described situation:
- 如果您在DNS中设置了CNAME,则可能还必须修改您的网络服务器以处理新的主机名,因为HTTP协议的工作原理如下
- @stevevis说过,您将失去Cookie和缓存,甚至失去搜索引擎中的排名
- 您仍然必须在您的地址中包含端口号:
http://mycname:40080/webapps/index.jsp
您没有提到,但我认为您不能修改Web服务器设置,因为在这种情况下,您也可以修改端口号.
You haven't mentioned but I assume that you cannot modify your webserver settings, because in this case you could modify the port number as well.
但是有一个小小的牺牲就可以解决这个问题.
But there is a solution for this problem with small sacrifices.
您可以安装HTTP反向代理服务器,以将请求转发到Web服务器(例如, HAProxy , nginx 等),但是您将失去原始客户端的IP地址(当然,您可以在HTTP标头,但您必须修改先前域上的代码才能处理此问题.
You can install an HTTP reverse proxy server to forward the requests to the webserver (for e.g. HAProxy, nginx, etc.) but with this you'll loose the original clients' IP address (of course you can forward it in an HTTP header but you have to modify the code on your previous domain to handle this).
这篇关于是否可以对< host:port>使用CNAME(别名)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!