简体   繁体   English

将进入端口80的流量直接引导到本地虚拟主机

[英]Direct incoming port 80 traffic to local virtual host

I am running MAMP Pro on a Mac and I have port forwarding set up on my router to forward traffic to my server. 我在Mac上运行MAMP Pro,并且在路由器上设置了端口转发功能,以将流量转发到服务器。 For now I just have an IP for my computer, no domain name or DNS setup, although I could do that. 到目前为止,尽管我可以这样做,但我只有计算机的IP,没有域名或DNS设置。 What I want to do is forward incoming traffic to a particular virtual host on my server. 我要做的是将传入流量转发到服务器上的特定虚拟主机。 eg MAMP has a localhost by default. 例如,MAMP默认具有本地主机。 I have a number of other virtual hosts, xxxx.local, and I would like to forward to a particular one. 我还有许多其他虚拟主机xxxx.local,我想转发给特定的主机。 Can I do that by editing httpd.config or the hosts file. 我可以通过编辑httpd.config或hosts文件来做到这一点吗?

Apache "sees" the "host name" of the incoming request and forwards it to the virtual host with the same same. Apache“看到”传入请求的“主机名”,并将其转发给具有相同请求的虚拟主机。 All other requests are captured from "localhost". 所有其他请求均从“本地主机”捕获。 It's called "single link multihoming",means one IP address for a lot of virtual hosts. 它被称为“单链路多宿主”,表示许多虚拟主机的一个IP地址。

Greetings, 问候,

Peter 彼得

I actually just pointed one of my domains to my home server IP and that works since it has a domain name and I have a local virtual host setup. 我实际上只是将我的一个域指向我的家庭服务器IP,并且可以正常工作,因为它具有域名并且我具有本地虚拟主机设置。 My original question was whether it is possible to do something like that if you just have an IP (ie can you send all requests to an IP to a particular single local virtual host rather than to the default localhost), and I guess the simple answer is no. 我最初的问题是,如果只有IP(是否可以将对IP的所有请求发送到特定的单个本地虚拟主机而不是默认的本地主机),是否可以执行类似的操作,我想简单的答案没有。 It forwards those to the localhost. 它将那些转发到本地主机。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM