apache virtual host question - apache

After i 've set a virtual host in httpd.conf,
why i still have to set the virtual host in domain registration organization?
I'clarify
for example , i've set phpmyadmin.mydomain.com as virtual host in httpd conf file, next, i've to go to http://www.dyndns.com/ to add phpmyadmin.mydomain.com as A record, so phpmyadmin.mydomain.com will be accessible.

After i 've set a virtual host in httpd.conf,
why i still have to set the virtual host in domain registration organization?
These are two separate tasks because they touch entirely different areas.
DNS records tell the world that domain A is now reachable on IP address B (Imperfect real world analogy: an entry in the phone book)
The VirtualHost directive tells the server software running on the server how to deal with incoming requests to that domain. (Imperfect real world analogy: Your name on the doorbell of a large house, and on your mail box in the hallway of the house.)

Related

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

Direct incoming port 80 traffic to local virtual host

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.

website can be accessed using ip but not with the url(domain name) in wamp

from default httpd.conf to updating the host file and httpd.conf i tried but the website fails to open with domain name give
in host file
<my current public ip address> <domain name>
in httpd.conf
Listen [my public ip]:port
then restart of wamp server and finally restart of PC and of-course change of ip is done in above all.
But of no use
Please help
Thanks for time and response
Aaron,
I think you are misunderstanding the function of the HOSTS file.
The hosts file acts a little like a local DNS Server. Any changes you make to it will only effect the single PC that you made the change on.
What the HOST file actually does
When windows starts it starts a service called DNS Client also known as dnscache. That service reads the HOSTS file and seeds the dnscache with any domain names you put in it and the ip that should be connected to for each domain name.
Any program (the browser in this case) that wants to connect to a domain, checks this cache first, to reduce accesses to an actual DNS Server out on the web and therefore speed up the conversion of domain name to Ip Address.
So if you want external users, i.e. anybody on the internet to be able to access your site you have to either purchase a real domain name and get it pointed to your WAN ip address, or use a Dynamic DNS service like DYNDNS or NO-IP, to mention only a few, and get that dynamic dns service to point to your WAN IP.
You will also have to change your Apache config so it will serve that domain name, my suggestion would be to create a Virtual Host to do this.
This post may help with the process of creating a Virtual Host

Apache 2 + virtual hosts on different folders

I have a folder named www with my applications:
/www/app1_folder/
/www/app2_folder/
/www/app3_folder/
Also I have one external ip and domain name www.example.org*.
If I refer my apps without virtual host settings It looks:
http://www.example.org/app1_folder/
http://www.example.org/app2_folder/
http://www.example.org/app3_folder/
But problem is my apps share a session environment.
I would like to save the approach of my apps referring (i.e http://www.example.org/app1_folder/, ...) without sharing of environment.
I hope it's possible with virtual host setting of apache.
How can I make virtual hosts based on different names of folder (i.e. app1_folder, app2_folder, app2_folder)?
A virtual host is defined by a domain name (foo.mysite.com) and a port (:80, ...).
You cannot create several virtual hosts by using the same domain name/port.

Multisite installation, each website should have different IP

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)