[SOLVED] Virtualbox +NAT Apache ProxyPass

Discussions related to using VirtualBox on Linux hosts.
Post Reply
talkinggoat
Posts: 7
Joined: 29. May 2011, 18:08
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: XP, Fedora

[SOLVED] Virtualbox +NAT Apache ProxyPass

Post by talkinggoat »

Please tell me what I'm doing wrong. I have a configuration where apache listens on an external interface, hosts a domain, and acts as a proxy for a couple of internal servers. For the most part, this works perfectly. When a specific url matches the proxypass directive, apache forwards to the internal site. However, I am trying to use NAT to forward to another virtual server, but it keeps forwarding to the host, but only from the outside. For example, This is the configuration of the proxy:

Code: Select all

<VirtualHost *:80>
   ServerName example.com
The host listens on port 12000 under the name example.com. ProxyPass forwards the root of the domain to the computer, hostmachine

Code: Select all

ProxyPass / http://hostmachine:12000/
The proxy forwards /billing to port 2080 on the hostmachine, which is forwarded, using vbox NAT, from port 2080, to port 80, under the name example.com/billing

Code: Select all

ProxyPass /billing http://hostmachine:2080/billing/
I am using NAT to forward port 2080 on the host, to port 80 of the virtual server.

Code: Select all

vboxmanage showvminfo server1
...
NIC 1 Rule(0):   name = http, protocol = tcp, host ip = , host port = 2080, guest ip = , guest port = 80
Here is the issue, when I direct an internal (even the proxyserver) browser to hostmachine:2080, I get the expected html file from the virtual server1. When I try to access it from the outside, routing through the proxy I get the html file from the hostmachine

From an internal computer:

Code: Select all

telnet hostmachine 2080
Trying 10.28.45.100...
Connected to hostmachine.
Escape character is '^]'.
GET /billing/index.html
test billing server1
Connection closed by foreign host.
From an external browser:

Code: Select all

http://example.com/billing
test billing hostmachine
From the outside, this is what should happen

Code: Select all

example.com:80/billing -> ProxyPass -> hostmachine:2080 -> 2080:NAT:80 -> server1:80/billing
What is happening

Code: Select all

example.com:80/billing -> ProxyPass -> hostmachine:80
Last edited by talkinggoat on 17. Aug 2017, 23:48, edited 1 time in total.
talkinggoat
Posts: 7
Joined: 29. May 2011, 18:08
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: XP, Fedora

Re: Virtualbox +NAT Apache ProxyPass

Post by talkinggoat »

Figured out the problem was with the proxy server. I forgot that Apache processes things in the order they appear, so I needed to place /billing in front of the /. For example, in the conf file for the domain,

Code: Select all

ProxyPass /billing http://hoststmachine:2080/billing/
THEN

Code: Select all

ProxyPass / http://hostmachine:12000/
Post Reply