Set virtual host for redirect to multiple web server (apache) - apache

Don't know what the perfect title for this, but here it is.
I'm running a server with Windows Server 2008 R2.
On this server I have three webapps and it already run well
App1 using Apache2 on port 80
App2 using IIS on port 81
App3 using Xampp Apache on port 83
I already have a domain for each port
1. domain1.com for port 80
2. domain2.com for port 81
3. domain3.com for port 83
all domain has been pointing to server, and it is work fine when I use (:port) behind the domain, eg. domain1:83 is already open Xampp Apache on port 83.
however, what I need is when I type domain1.com it should open port 80, domain2.com it should open port 81, and domain3.com should open port 83.
Simple say, I don't need to add :81 or :83 if I want to open those sites.
Main apache server used are Apache2, and I need configuration to automatically when I type domain2.com it goes to port 81 (localhost:81), and so if I type domain3.com it goes to port 83 (localhost:83)
Meaning is, that Apache2 only handle App1 on port 80, when I want to access App2 using domain2.com then it refer to localhost:81 then the process will be handled by IIS, and so for App3 using domain3.com it refer to localhost:83 then Xampp will handle the process.
Every Apps has different config so I cannot put it to single port 80 then difference it by DocumentRoot since other Apps are not processed by Apache2.
Regards,

Set up a name-based virtual host support on Apache. It is handling port 80, so it will handle all requests to port 80, no matter what port number is used.
You then have two options.
Redirect
Proxy
You can redirect the traffic to the other port (which will show the port number in the address bar of the browser, and cause search engines to index URLs with that port number in them)
Redirect / http://domain2.com:81/
Or you can proxy the traffic through Apache (which will relay everything through Apache, which could have performance implications):
ProxyPass "/" "http://domain2.com:81/"

Related

Stopping https port on wsubdomain

I would like to set a server on port 443 to handle safari web notifications. So I would like to disable port 443 from Apache for that subdomain. I tried doing it by removing the web domain from ssl.conf or setting SSLEngine off after putting the domain on port 80, but in all cases when I execute nmap on the domain port 443 always pops up, and when I execute the other service on port 443 I get an error.
How do I manage it?

define subdomain apache's vhost with lighttpd

Apache is runnig my server with port 80 and lighttpd with 81.
I defined vhost abc.com in apache.
I want to define track.abc.com and all request goes to lighttpd. Is is possible to define track subdomain for abc.com in lighttpd?
It is possible but rather than ports you need to have 2 separate IP addresses if you want to make regular request http://www.domainname.com in your browser. Otherwise you will be forced to call http://www.domainname.com if you intend to use the same IP address for both Apache and Lighttpd server.
You need to declare listening port in both Apache config and Lighttpd otherwise they both would try to bind IP address and port 80 which will result in error and only first server would start up.
I research and answer is Apache's ProxyPass option. First I configured my subdomain on Apache's vhost. and I added my subdomain's chost config file
ProxyPass / http://my_host_name:81/
Now, all my subdomains request goes to lighttp.

Get user machine's IP address when a website is configured with Apache Varnish in front of Tomcat

Currently, I am running a website which is running on Tomcat which has Apache in front and varnish for caching. Tomcat is running on port 8080 and port 81 is used as varnish back end. I need to implement a feature for which I need to know the IP address of the client's machine visiting the website. I've tried to access the IP address by the header X-FORWARDED-FOR.
When the website is accessed from port 81 (i.e. http://mywebsite.com:81/) I can get the IP address of the client's machine but unfortunately when accessing through default port 80 (i.e. http://mywebsite.com/) it's returning the localhost IP address (127.0.0.1). Can anyone suggest what can be the worked around to get the user's real IP address from port 80 as well?
Your setup, if I understood correctly, is as follows:
Varnish (port 80) -> Apache (port 81) -> Tomcat (port 8080)
And you would like the actual remote IP to show up as REMOTE_ADDR on the Tomcat server.
Varnish appends X-Forwarded-For header by default, so that's already sorted. To get Apache to pass the actual remote IP to Tomcat, you should install reverse proxy add forward module for Apache (mod_rpaf). mod_rpaf does exactly what you're looking for. The appropriate config for Apache would be:
<IfModule !rpaf_module>
LoadModule rpaf_module modules/mod_rpaf-2.0.so
</IfModule>
<IfModule rpaf_module>
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1
RPAFheader X-Forwarded-For
</IfModule>
After enabling the module Tomcat should see the correct REMOTE_ADDR header as well as the HTTP_X_FORWARDED_FOR header.

WAMP apache httpd.config and hosts - how to alias localhost to port 8080?

Ok so I configured my apache installation on Windows 7 such that it listens on port 8080 by changing the respective entry in httpd.config.
I was too stupid to realize that now I have to access localhost with :8080 at the end.
Question: is there a way to have my box automagically resolve localhost to 127.0.0.1:8080 ? I don't like haviog to type :8080, and NO I CANNOT change the port to 80, I need that one for firewall.
Thanks
no. hostnames have nothing to do with ports. You'll have to specify the port yourself, or set up a proxy on the usual port 80 that will do the 8080 requests on your behalf. ... or bite the bullet and use port 80 directly and move your firewall elsewhere.

Forward requests coming into port 80, for a particular link, to port 8080 locally

I have 2 web forms, one coded using Java Servlets on glassfish (port 8080) and another using PHP on apache(port 80). But my office ITdept is refusing to open port 8080 to outside traffic.
How do I set up Apache such that requests coming in for the form with the servlets are directed to port 8080?
Thanks
TX
PS: Im using wamp
Using the ProxyPass directive is how it's normally done.
ProxyPass /url/ http://127.0.0.1:8080/url/