Re: Virtual Host port forwarding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi zzzz.
Why do you post your messages 3 times ?

Other comments down further.

zm wrote:
Hi,

I've installed Apache HTTP Server 2.2.11 and I'm trying to configure it to
do the following trick:

I have 1 server, connected through 1 router. I payed for domain
"mydomain.com" (ficticious), and it will point toward my router with
success.

My router forwards port 80 to my server IP (192.168.1.1), also to port 80.

In my server, I have 2 services running:

Apache HTTP server on port 80
Webserver (tomcat) on port 8080
SVN server on port 8081

I want my apache server on port 80 to make the following forwardings:

if "www.mydomain.com" forwards to "192.168.1.1:8080"
if "svn.mydomain.com" forwards to "192.168.1.1:8081"
if anything else, fails ... or maybe to a static apache server page that
presents some static html page, saying "hello there, go away" (it could be
defined on apache http server itself).

Is it possible to do that?

Yes.

But the first think you need, is that the DNS system, from outside on the Internet, would know that "www.mydomain.com" and "svn.mydomain.com" both resolve to the same public IP address of your router.
Is that so ?
(Otherwise, nothing below will work)(and no other method will either, because requests for "www.mydomain.com" and "svn.mydomain.com" would not even reach your router.)


What configs should I put on "httpd.conf" VirtualHost?

I'm trying with something like:
<VirtualHost www.mydomain.com:80>
    ServerName 192.168.1.1:8080
</VirtualHost>
<VirtualHost svn.mydomain.com:80>
    ServerName 192.168.1.1:8081
</VirtualHost>

Should this work?

No, do this instead :

load mod_proxy and mod_proxy_http in your server

# following line only once
NameVirtualHost *:80

<VirtualHost *:80>
  ServerName localhost        (or really whatever you want)
  DocumentRoot /some/place/nice
  DirectoryIndex index.html
  # and as /some/place/nice/index.html, a page saying "go away"
  ...
</VirtualHost>
<VirtualHost *:80>
  ServerName www.mydomain.com        (must be so)
  ProxyRequests Off
<Proxy *>
  Order deny,allow
  Deny from all
  Allow from (internal IP address of your router)
</Proxy>
  Proxypass / http://localhost:8080/
  ProypassReverse / http://localhost:8080/
  ...
</VirtualHost>
<VirtualHost *:80>
  ServerName svn.mydomain.com        (must be so)
  ProxyRequests Off
<Proxy *>
  Order deny,allow
  Deny from all
  Allow from (internal IP address of your router)
</Proxy>
  Proxypass / http://localhost:8081/
  ProxypassReverse / http://localhost:8081/
  ...
</VirtualHost>

That's really the bare bones.
Look up each of these directives here, and understand what they do :
http://httpd.apache.org/docs/2.2/mod/directives.html


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux