Actually I am a beginner to the concept of virtualhost in apache so forgive me if I am being silly here. My question is :-
Is there a way that I can bind apache to listen on public IP/network interface of other server like Listen 54.27.123.255:80
Generally we use :
Listen 80
Listen 127.0.0.1:80
If you have multiples IP addresses on the one machine (e.g. multiple NIC cards) then you can use that syntax to have Apache, or certain vhosts in Apache, to only listen on one. For example you could have one vhost serving a site on one IP address and another vhost serving a different site on a different IP address which also resolves to that server. If you do not supply an IP address but just a port then Apache will listen to all IP addresses.
What you cannot do is use that syntax to steal network traffic for an IP address associated with another server - to do that Apache would need to be running on the server that IP address is associated with.
Related
We are setting up for the HTTP configuration for our project with the httpd
But our physical IP address and the virtual IP address is not the same
Where the physical IP address is system IP address and virtual IP address is added in DNS configuration.
We need to setup httpd with the virtual IP address. not with the system IP address.
How can I do this without changing the DNS entry?
Please let me know the configurations for the httpd.
thank you.
You only need to bind http on port 80 (and 443 if you are not off-loading the secure layer).
Every request reaching your apache will be served according to the configuration (plain, virtualhost, etc).
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
I am running MAMP Pro on a Mac and I have port forwarding set up on my router to forward traffic to my server. For now I just have an IP for my computer, no domain name or DNS setup, although I could do that. What I want to do is forward incoming traffic to a particular virtual host on my server. e.g. MAMP has a localhost by default. I have a number of other virtual hosts, xxxx.local, and I would like to forward to a particular one. Can I do that by editing httpd.config or the hosts file.
Apache "sees" the "host name" of the incoming request and forwards it to the virtual host with the same same. All other requests are captured from "localhost".
It's called "single link multihoming",means one IP address for a lot of virtual hosts.
Greetings,
Peter
I actually just pointed one of my domains to my home server IP and that works since it has a domain name and I have a local virtual host setup. My original question was whether it is possible to do something like that if you just have an IP (i.e. can you send all requests to an IP to a particular single local virtual host rather than to the default localhost), and I guess the simple answer is no. It forwards those to the localhost.
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.
I have 17 sites with a multisite installation and uses the domain access module. This means that I have the same code base and same database for all 17 sites.Is it possible to configure Apache(hosting server) in such a way that all sites have a different IP even if the physical location for all sites is same?
Sure, if your server is set up to accept traffic for each IP, you just need to use IP-based VirtualHosts instead of name-based VirtualHosts.
Namely, you'll need to have Apache Listen directive for each IP address in apache.conf, and each VirtualHost block would have to reference the IP address its listening on.
More info:
Creating Name and IP Based Virtual hosts in debian (it's not really just for Debian)
Name-based hosts on more than one IP address (VirtualHost Examples)