1

I am trying to configure a virtual host on my Windows machine using Apache and HOSTS file combination.

For example, I want www.example.com to be served from my server at localhost. However, port 80 is taken up by a Citrix process which can't be changed.

So, my httpd is running on 81. I want to be able to achieve the following.

  1. I hit http://www.example.com on my browser.
  2. Apache Virtual Hosts configuration should receive this request despite running on 81. (This is where my worry lies!)
  3. Serve pages from http://localhost:81/htdocs.

Is this possible at all?

Following is relevant section in my httpd.conf:

ServerName www.example.com:81
NameVirtualHost www.example.com:81

And my hosts file has the below line:

127.0.0.1 www.example.com

1 Answer 1

1

Put following snippet in httpd.conf and see if it works. It internally forwards all requests to http://localhost:8080/rat to http://localhost:9080/rat

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass /rat http://localhost:9080/rat
ProxyPassReverse /rat http://localhost:9080/rat

URL in browser remains as http://www.example.com:8080/rat but content is served from http://localhost:9080/rat

5
  • But what if 8080 is taken by a non-httpd process to which I don't have access?
    – adarshr
    Nov 21, 2011 at 14:57
  • If you want httpd to run on different ports you need to listen on different ports and ports must be free .Or there must be two network interfaces. pls see httpd.apache.org/docs/2.0/vhosts/examples.html#port Nov 21, 2011 at 15:18
  • I think what I am trying to do, can't be achieved. I want httpd to run on 81 and yet be able to hit example.com (80) on my browser. Which is kind of impossible unless I have my httpd listening on both 80 and 81. What do you think?
    – adarshr
    Nov 21, 2011 at 15:35
  • yep, I don't doubt so ;) unless there are two network interfaces (= two IP address) and Citrix process is listening on either one, and you could map other IP to apache ! Nov 21, 2011 at 15:45
  • 1
    I have actually figured out how to change Citrix configuration to point to a different port. But, here we logon remotely ONLY to our desktops and I'm afraid I will lose the connection and won't be able to reconnect again if I mess something up. I will live with www.example.com:81 for now :)
    – adarshr
    Nov 21, 2011 at 15:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .