is it possible to use CNAME (alias) for

前端 未结 4 2036
梦谈多话
梦谈多话 2021-01-07 19:10

Is there a way i can hide the port from url and use cname (alias) instead of :.

For e.g. If my url is http://myserver.com:40089/webapps/index.jsp Is its possible for

相关标签:
4条回答
  • 2021-01-07 19:20

    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:

    • if you set the CNAME in your DNS you probably have to modify your webserver as well to handle the new hostname because HTTP protocol works like this
    • as @stevevis said you'll loose your cookies and caches and even the rankings in the search engines
    • you still have to include the port number in your addresses: http://mycname:40080/webapps/index.jsp

    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.

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

    0 讨论(0)
  • 2021-01-07 19:23

    yes and no... yes you can use the cname interchangeably (though keep in mind that cookies may not go along for the ride depending on their domain), but if your server is running on a port other than 80, you'll have to include the port number in the URL.

    0 讨论(0)
  • 2021-01-07 19:35

    Try using a SRV record for doing that. It is what I used to get a custom domain for my minecraft server.

    0 讨论(0)
  • 2021-01-07 19:37

    No. CNAME only maps names, not ports. You need a reverse proxy if you want to map x:b to c:d.

    0 讨论(0)
提交回复
热议问题