Two webserver in same instance for different domains - apache

I am running two web-server in one AWS instance, One Lamp stack apache(a.com) and a Bitnami's apache(b.com). Apache is using port 80 which is my default port and Bitnami is using port 8080. How can I point two domains to the same instance so that it will show up the content for a.com and b.com. And same time the port number shouldn't be visible out side. I tried with virtual-host found out its impossible since I have a separate virtual host file for Bitmani.

Both servers should serve the same content using same website but with different virtual host configuration files ??
Instead of using two webservers, increase the cpu and core capacity and enable worker MPM and increase process count and use virtual host configuration with two different ports.

Related

Setting firewall rules to enabling running Apache2HttpServer and ApacheTomcat 9 on the same machine with two different hostname/ip:port

I have a Virtual Machine Linux Debian 10, with two Host-Only Network interfaces actived respectvely 192.168.56.10 and 192.168.56.15 with static ip address.
Apache Tomcat 9 is installed and Apache2 Http Server is installed too.
My purpose is that Apache Tomcat 9 must run on 192.168.56.15:8080,
while Apache2 Http Server must run on 192.168.56.10:80.
The /etc/hosts file in my Linux is:
#
192.168.56.10 www.example.com
192.168.56.15 openam.example.com
#
The C:\Windows\System32\drivers\etc\hosts is the same.
In short I'm trying to setup a small development enviroment for Identity and Access Managment using the Forgerock's AM solution. That software has to be deployed as a .war file (openam.war) in Tomcat /webapps and it will be mapped as openam.example.com, and I want this service run on
192.168.56.15:8080/openam;
So my problem is that I want two different services responding two different interfaces but running on the same Virtual machine.
I want that only if i type 192.168.56.15:8080 or openam.example.com:8080 I recive a respond from Tomcat, but if I type 192.168.56.15:80 or openam.example.com:80 Apache Http Server doesn't have to respond. Apache Http Server have to respond only on 192.168.56.10:80 or www.example.com.
In this way I can have like two different machines one with the web server and one with the application server, responding on two different IP addresses and hostname, but running on the same machine.
Thanks for help!
You could have 2 IPs but what's the point in doing so?
I find it rather pointless to have 2 separate IPs for 2 different services on the same machine (e.g tomcat on 1 / HTTP server on the other) for a development environment inside a VM. Port handling will be handled by the operating system itself and route the request to the open port.
Keep in mind that browsers will try to connect http:// calls on port 80 by default - so unless you type 8080 into the URL the browser it is just going to use port 80.
If you do not want calls to openam.example.com to come in on port 80, the simplest way round it is to use a htaccess rule that implements a rewrite for any request that contains openam.example.com (or just anything in a subdomain portion) on port 80 to be rewritten to the appropriate URL.

Port forward port 80 to diff websites depending on sub-domain wherein contents reside in diff machines

In the coming months I'll be creating different websites. Actually, one has been up already for awhile but I shut it down because of internet issues.
My issue now is I want to create another website but just under a certain sub-domain. I want to do this so that I can maximize my domain. So I'll be creating say:
1. www.example.com
2. api.example.com
3. xyz.example.com
My home router forwards port 80 to a certain local IP 192.168.0.3 which is a virtual machine. I want to make contents of different websites to reside in different VMs to avoid conflicts. So those 3 websites, are in different VMs.
Now, how can I set my router to target a VM depending on the website being requested provided that my router only targets one IP to port forward port 80?
Am I correct that I'll be using reverse proxy of Apache2?
Update: Is this an ideal solution on websites with this setup? If not how is large corporations set it up?
first you have to configure the dns server of your domain to forward all domains to the same ip address (use some a A-Records)
a-record
and then configure Name-based virtual hosts in the configuration of your apache webserver.
Name-based virtual hosts
in this Virtual hosts you can forward to the VMs

Installing multiple web servers on a dedicated server. CentOS

I have a dedicated server with 16 IPs. I wanted to know if its possible to install multiple web servers running off the different IPs. What would be the best way to do this? (I believe its possible, because how do web host reseller sites do it?). I am using CentOS 6. Thanks
Most host or resellers do not have one IP for each website; instead they use virtual hosts to allow one web server to serve multiple domains.
Once a process is listening on port (for example, port 80 which is HTTP) of an interface, that's it - you can't have another server or process listening on the same port.
As you have 16 IPs, you can run 16 servers - one listening on port 80 at each IP address.
Then further, each server can host multiple websites as virtual hosts.
You don't need 16 IPs though - you can host multiple websites using one IP.

why to have Apache Web Server listening on more than one port

What's use to have a Apache Web Server listening on more than one port?
Can any one explain me the use case?
You may want to use both IPv4 and IPv6, use HTTP and HTTPS, etc.
http://httpd.apache.org/docs/2.2/bind.html
You may have multiple network providers, and multiple IP's provided by each. Though listening to 0.0.0.0 will listen to all addresses, sometimes you may want to listen to selected addresses, not all of them.
Edit: Forgot: also an important reason is when you have to serve multiple sites and multiple domains from one host (one IP). You will then use different ports for each different site. They are so called name-based virtual hosts.
If you'll need it, here's a link on how to name-based virtual hosts from apache docs.
I can see at least two possible use cases for that:
Assuming that your application is accessible to the public via port 80. But you wish to manage your database via phpmyadmin (a php tool to manage MySQL servers). Because of that you could configure Apache web server in a way, that it would listen on some other "private" port for phpmyadmin calls. This way, only you and your team can access it.
When you don't have registered domain names with you, you can create multiple sites running on your server and assign different ports to different sites. This way, you could test your site until your domain name gets registered.
well... for http the default port is 80 and HTTPS default is 443
and you can serve in another port for some reason.

SSL with Virtual Hosts on Apache in Amazon AWS EC2 environment

I am trying to set up two virtual hosts served over SSL on Apache in Amazon AWS environment.
I understand that SSL cannot use Name Virtual Host on Apache unless:
* I bind two IPs to Apache each serving a separate virtual host. Unfortunately, AWS does not allow me to bind more than one public IP to each EC2 machine
* or I use SNI (server name identification) which does not work for IE6 or WinXP (all browsers).
Is my understanding correct?
If yes, what are my options on AWS where I cannot bind two IPs and if I want to server my site to WinXP and IE6?
The only thing I can think of setting up two new micro instances with proxy servers each serving each instance and the forwarding to the actual server.
Is there a better option?
I'm using UCC for several sites using one IP.
See also this thread:
SSL on a single server for multiple web sites