创建一个指向非80端口IP的域名 [英] create a domain name pointing to an IP of port different than 80

查看:26
本文介绍了创建一个指向非80端口IP的域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用域名指向本地服务器IP地址上的网页.但是,问题是该页面链接到在端口 8088 而不是 80 上设置的 IP 地址,因为后者已被另一个网页使用.域公司告诉我他们不能这样做,因为域只能指向在端口 80 上设置的 IP 地址.所以现在我陷入了僵局.我有哪些替代方案,如何使域指向 IP:8088?

I would like to use a domain name to point to a web page on the local server's IP address. However, the problem is that the page is linked to an IP address set up on port 8088 rather than 80 because the latter is already used by another web page. By the domain company I was told that they cannot do it because the domain can only point to an IP address set up on port 80. So now I am in a deadlock. What alternatives do I have and how can I make a domain pointing to the IP:8088?

谢谢

推荐答案

与您交谈过的域公司可能在解释域的工作原理方面做得很差.域名不指特定端口.它们只是指 IP 地址.客户端可以查找主机名以获取客户端应该连接的 IP 地址,但客户端必须在没有 DNS 帮助的情况下找出端口.80端口只是HTTP服务的默认端口.

The domain company that you talked to may have done a poor job of explaining how domains work. Domain names don't refer to specific ports. They just refer to IP addresses. The client can look up a hostname to get the IP address which the client should connect to, but the client has to figure out the port without the help of DNS. Port 80 is just the default port for HTTP service.

如果您愿意,您当然可以在端口 8088 上运行 Web 服务器.端口号必须出现在 URL 中,例如http://somehost.example.com:8080/some/page.客户端会解析它并知道连接到端口 8080 而不是默认端口 80.

You can certainly run a web server on port 8088 if you like. The port number would have to appear in the URL, e.g. http://somehost.example.com:8080/some/page. Clients would parse this and know to connect to port 8080 instead of the default port 80.

如果您不希望 URL 包含端口号,那么请求将转到默认端口 80,您别无选择,只能让运行在端口 80 上的 Web 服务器处理这些请求.HTTP/1.1 请求包括客户端想要联系的主机名,现代 Web 服务器程序通常能够根据请求中的主机名提供完全不同的内容集.有几种方法可以满足您的需求:

If you don't want URLs to contain the port number, then requests are going to go to the default port 80, and you have no choice but to make the web server running on port 80 handle these requests. HTTP/1.1 requests include the hostname which the client wants to contact, and modern web server programs are normally capable of serving completely different sets of content based on the hostname in the request. There are few ways todo what you need:

  1. 只需为端口 80 配置 Web 服务器即可处理这两个站点.这将取决于您使用的 Web 服务器软件.例如,Apache 将这些称为虚拟主机",这里有一组示例.这是一个典型的解决方案,有些人以这种方式在同一台服务器上运行数百个站点.

  1. Just configure the web server for port 80 to handle both sites. This will depend on what web server software you're using. Apache for example calls these "virtual hosts", and here is a set of examples. This is a typical solution, and some people run hundreds of sites on the same server this way.

按您的计划运行您的两个 Web 服务器.将端口 80 的服务器设置为第二个网站的反向代理.服务器将继续为它现在处理的站点提供内容.当它收到对第二个站点的请求时,它会将请求中继到运行在端口 8088 上的服务器,并将服务器的响应中继回客户端.

Run your two web servers as you planned. Set up the server for port 80 to be a reverse proxy for the second website. The server would continue to serve content for the site it handles now. When it receives a request for the second site, it would relay the request to the server running on port 8088, and relay the server's response back to the client.

将端口 80 的现有服务器移动到其他端口.在端口 80 上运行纯反向代理服务器,将两个网站的请求中继到各自的网络服务器.

Move the existing server for port 80 to a different port. Run a pure reverse proxy server on port 80, relaying requests for both web sites to their respective web servers.

您最好向https://webmasters.stackexchange.com/https://serverfault.com/.

这篇关于创建一个指向非80端口IP的域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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