简体   繁体   English

将HTTP流量转发到虚拟内部网络上运行的Web服务器

[英]Forward http traffic to web server running on virtual internal network

I'm running VirtualBox on OSX host with Debian guest. 我正在使用Debian guest在OSX主机上运行VirtualBox。 I use Debian to run my development LAMP environment and I would like all traffic on my host port 80 to be automatically forwarded to the Debian guest. 我使用Debian运行我的开发LAMP环境,并且希望将主机端口80上的所有流量自动转发给Debian来宾。

Currently my debian server is set up with 2 network adapters, one Host-Only and one NAT (the latter simply to give it an internet connection, it's not meant for server duty). 目前,我的debian服务器设置了2个网络适配器,一个仅主机和一个NAT(后者只是为了建立Internet连接,并不意味着要承担服务器职责)。

On my OSX host I've configured mod_proxy like so: 在OSX主机上,我已如下配置mod_proxy:

ProxyPass / http://debian/

(debian being the hostname of the debian guest). (debian是debian guest的主机名)。 This works for me as my host shares an internal network with "debian", however if I quickly want to show something to a collegue and send them my url (192.168, etc) then they won't be so lucky. 这对我来说很有效,因为我的主机与“ debian”共享一个内部网络,但是,如果我很快想向同事展示一些东西并将其发送给我(例如192.168等),那么他们就不会很幸运了。

How can I set up my configuration in such a way that my OSX apache server basically acts as a full on proxy solution for my debian server? 如何以OSX apache服务器基本上充当debian服务器的完全代理解决方案的方式设置配置?

Thanks 谢谢

If I'm reading your question correctly, it sounds as though you understand ProxyPass to work similar to an HTTP 301/302 status, which is incorrect. 如果我正确阅读了您的问题,听起来好像您了解ProxyPass可以类似于HTTP 301/302状态一样工作,这是不正确的。 A 302 HTTP status will say to the requesting client, "Hey, get this from some other address yourself." 302 HTTP状态将对发出请求的客户端说:“嘿,您自己从其他地址获取它。” In this case, debian would have to be visible to your colleague. 在这种情况下,您的同事必须可以看到debian

However, ProxyPass (and reverse proxies in general) make the connection for you ; 但是, ProxyPass (通常是反向代理) 为您建立连接; the client doesn't need to (and very often doesn't) have direct access to the upstream server, in this case debian . 客户端不需要(而且通常不需要)直接访问上游服务器(在本例中为debian Long story short, unless I'm reading this wrong, you should be good already, as long as Apache on your host machine (your physical box) is listening on an IP address they can see. 长话短说,除非我读错了,否则只要您主机(您的物理设备)上的Apache正在监听他们可以看到的IP地址,您就应该已经不错了。

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

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