设置 HTTP 标头并将其发送到 IP 地址的最简单方法

发布于 2024-07-25 14:34:03 字数 156 浏览 0 评论 0原文

我使用的是虚拟主机,所以我有一个共享的IP地址。 我想通过将主机名 http 标头发送到 IP 地址来访问我的测试站点,以便服务器可以解析名称并发回我的站点页面。 我在服务器上使用未注册的域名,因此无法仅在浏览器中输入网址。 有谁知道设置 HTTP 标头并将其发送到 IP 地址的最简单方法?

I am using a virtual host, so I have a shared IP address. I would like to access my test site by sending the hostname http header to the IP address, so the server can resolve the name and send back my site page. I am using an unregistered domain name on the server so I can't just type the url into the browser. Does anyone know the easiest way to set an HTTP header and send it to an IP address?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

不念旧人 2024-08-01 14:34:03

将 IP 和主机名添加到您的主机文件

# Example
88.99.100.1       yourwebsitename.com

http://en.wikipedia.org/wiki/Hosts_file

add the ip and hostname to you hosts file

# Example
88.99.100.1       yourwebsitename.com

http://en.wikipedia.org/wiki/Hosts_file

淡淡離愁欲言轉身 2024-08-01 14:34:03

从命令提示符处:

telnet 127.0.0.1 80
GET / HTTP/1.1
Host: example.com

将 IP 地址和主机名替换为您关心的内容。

From a command prompt:

telnet 127.0.0.1 80
GET / HTTP/1.1
Host: example.com

Replacing the ip address and host name with the ones you care about.

琉璃繁缕 2024-08-01 14:34:03

没有直接回答问题,而是为了在 DNS 条目传播之前测试虚拟主机,我在本地主机文件中添加了一个条目。 它通常驻留在 GNU/Linux 上的 /etc/hosts 中,以及类似的 Windows 上的 %WINDIR%\system32\drivers\etc\hosts 中。

现有条目应该能让您了解要添加哪些内容。

Not answering the question directly, but to test virtual hosts before the DNS entry has propagated in the past I've added an entry to my local hosts file. This usually resides in /etc/hosts on GNU/Linux and similar and %WINDIR%\system32\drivers\etc\hosts on Windows.

Existing entries should give you an idea of what to add to it.

流殇 2024-08-01 14:34:03

将备用 IP 地址添加到主机上的网卡,并将此 IP 地址用于 Web 服务器。 或者,您可以在虚拟机中设置 IP 地址并使用它。

作为另一种选择 - 让系统管理员更新您的 DNS 服务器; 假设您使用的是 IIS,为您的 Web 服务器添加别名并设置标头来处理这些请求。 我不确定如何在其他网络服务器上执行此操作。

要更新 DNS 设置,请在域控制器上转至 DNS 管理控制台并浏览到正向查找区域中的相应域。 添加新别名并将其指向 Web 服务器。 别名可能类似于 MyWebApp.MyDomain.Local,并指向 MyWebServer.MyDomain.Local。

如果这听起来像是一种合适的做事方式,请告诉我,我将添加一些有关如何执行此操作的更多详细信息。

这可能无法回答所提出的问题......:-\

Add an alternative IP address to the network card on the host, and use this IP address for the web server. Alternatively, you can set the IP addres in the virtual machine and use that.

As another alternative - have a sys admin update your DNS server; add aliases for your web server and set up your headers to handle these requests, assuming you're using IIS. I'm not sure hw to do this on other web servers.

To update DNS settings, on a domain controller go to the DNS management console and browse to the appropriate domain in the forward lookup zone. Add a new alias and point it at the web server. The alias may be something like MyWebApp.MyDomain.Local, and point at MyWebServer.MyDomain.Local.

If this sounds like a suitable way to do things, let me know and I'll add some more detail on how to do this.

Which might not be answering the question asked... :-\

秋意浓 2024-08-01 14:34:03

您还可以使用 DynDNS 服务,免费注册子域(例如 mywebsites.homedns.org)并启用通配符子子域。 然后,您可以将 foo.mywebsites.homedns.org 添加到虚拟主机 ServerAlias 并转到 http://foo.mywebsites。 homedns.org

You can also use the DynDNS service, register a subdomain (like mywebsites.homedns.org) for free and enable wildcard subsub-domains. Then you can add foo.mywebsites.homedns.org to the vhost ServerAlias and go to http://foo.mywebsites.homedns.org.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文