michael
michael

Reputation: 4483

Apache mod_proxy - Pass through from localhost to another domain?

I'm not at all experienced when using proxies but hopefully this is possible.

I have apache running on my development machine which hosts a website (www.testdomain.com). I need to look at www.testdomain.com from my phone. I don't want to root my phone so all I can do is enter the IP address of my machine (10.8.0.1). The site hosted at www.testdomain.com won't work correctly as the default site in apache.

I need some way of passing through a request to 10.8.0.1 to www.testdomain.com without my phone having to look up the DNS record for www.testdomanin.com

Is this possible using mod_proxy? Is there something else that will do the job?

Upvotes: 1

Views: 2313

Answers (1)

arg
arg

Reputation: 187

First of all, I don't really understand why can't you point your cellphone browser to www.testdomain.com.

Anyway, you could use a proxy, but I think a better approach would be to use a ServerAlias directive in your www.testdomain.com vhost:

<VirtualHost *:80>
    ServerName www.testdomain.com
    ServerAlias 10.8.0.1
    (...)

If you still want to use a proxy, you could setup a different vhost for 10.8.0.1:

<VirtualHost *:80>
    ServerName 10.8.0.1
    ErrorLog ...
    TransferLog ...
    LogLevel warn

    # ReverseProxy
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass        / http://www.testdomain.com/
    ProxyPassReverse / http://www.testdomain.com/
    (...)

ref: http://httpd.apache.org/docs/current/vhosts/name-based.html

Upvotes: 1

Related Questions