logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Config apache - Virtualbox guest browser to localhost port
Author
number3



Joined: 22 Dec 2016
Posts: 4
Location: Mississauga

PostPosted: Wed 28 Dec '16 21:32    Post subject: Config apache - Virtualbox guest browser to localhost port Reply with quote

Hey guys, I hope everyone has a happy holidays.

I have a local web server where I am running an application on a specific port (9000) and I would like for the Guest VM to be able to access the app running on port 9000 of my local host.

I'm looking for help/advice on whether this is possible and what do I need to do to achieve this.

Here is what I currently have

* Apache running on my local machine
* I have an app running on localhost port 9000
* I have a Virtualbox VM running Windows7
** When I'm in the VM and I access test.example.com, I would like the request to actually go to my host machine's web server at localhost:9000
*** The app on localhost:9000 returns data as a response (I just want to clarify, that I'm not just displaying a page on 9000)
*** My virtual machine network setting is set to NAT
*** When I go to 10.0.2.2, I can reach the document root of my local web service without any issues
* In my VM guest hosts file I have the following entry:
Code:
10.0.2.2 test.example.com

* In my localhost apache config I have the follow virtual host

Code:
             <VirtualHost 10.0.2.2:80>
               ErrorLog "/var/log/apache2/vh1.com_log"
               ProxyPreserveHost On
               ProxyRequests Off
               ServerName test.example.com
               ProxyPass / http://localhost:9000/
               ProxyPassReverse / http://localhost:9000/
            </VirtualHost>


Anyone have any thoughts on whether I'm going in completely the wrong direction?

Please let me know what I can provide to clarify.

Thanks for the replies

System information:
Apache version:
Code:
Server version: Apache/2.4.18 (Ubuntu)
Server built:   2016-07-14T12:32:26

- operating system
Code:
Ubuntu 16
Back to top
Izomye



Joined: 15 Dec 2016
Posts: 17
Location: Hammerfest

PostPosted: Thu 29 Dec '16 16:30    Post subject: Reply with quote

Hi,

Which module have you loaded for this one?
Back to top
number3



Joined: 22 Dec 2016
Posts: 4
Location: Mississauga

PostPosted: Thu 29 Dec '16 17:51    Post subject: Reply with quote

Izomye wrote:
Hi,

Which module have you loaded for this one?


Hey Izomye, I ran this command to enable the proxy module:

Code:
/usr/sbin/a2enmod proxy
Back to top
Izomye



Joined: 15 Dec 2016
Posts: 17
Location: Hammerfest

PostPosted: Sat 31 Dec '16 14:42    Post subject: Reply with quote

Code:
ProxyPreserveHost On


When enabled, this option will pass the Host: line from the incoming request to the proxied host, instead of the hostname specified in the ProxyPass line.

This option should normally be turned Off. It is mostly useful in special configurations like proxied mass name-based virtual hosting, where the original Host header needs to be evaluated by the backend server.

Pleset set it off and testing again.

and the question for me:

Get you in the addresslist "10.0.2.2", then get not a answer from the webserver?

Get you in the addresslist "test.example.com", then get an answer with your page?
Back to top
number3



Joined: 22 Dec 2016
Posts: 4
Location: Mississauga

PostPosted: Wed 08 Feb '17 18:26    Post subject: Starting from scratch Reply with quote

Okay I will start from square one and describe my problem rather than presenting my apache config.

On my host machine I have apache running on localhost port 9000 and I also run an app using gulp on localhost port 80.

The first issue I have is that I virtual machine (windows based), where I want to be able to access the web pages on my host machine (localhost:9000).

My second issue is that from my virtual machine I would like to forward requests from a URL (ex: http://gulp.app.com) to my web app hosted on localhost:80). The reason for this is that my gulp app returns a response that needs to be parsed.

Any help on how I can configure my Apache to forward requests to the correct ports?

Thanks.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Fri 10 Feb '17 18:47    Post subject: Reply with quote

I would use a name based vhost instead of the IP based vhost.

only
Code:

<VirtualHost *:80>
Back to top
number3



Joined: 22 Dec 2016
Posts: 4
Location: Mississauga

PostPosted: Tue 14 Feb '17 16:39    Post subject: Reply with quote

Thanks for the post James.

I this case how would using an name based vhost help? If you could provide some details. As I want to tackle this problem from square one discard the approach I previously tried.
Back to top


Reply to topic   Topic: Config apache - Virtualbox guest browser to localhost port View previous topic :: View next topic
Post new topic   Forum Index -> Apache