I have two server VM with centos 7. With IP public 103.x.x.78 and domain one.example.go.id
This IP local is 192.168.10.200 (Server A).
I created another one VM with IP local 192.168.10.103 (Server B). With planned to pointing my other domain two.example.go.id
This my configuration:
one.example.go.id pointing to 103.x.x.78
I have create VirtualHost with DocumentRoot /var/www/html and work.
Then
two.example.go.id pointing to 103.x.x.78
I try to open this domain worked. Open webpage.
Create /etc/hosts at Server A:
192.168.10.103 two.example.go.id
And create VirtualHost at Server B
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.two.example.go.id
ServerAlias two.example.go.id
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:443>
ServerName www.two.example.go.id
ServerAlias two.example.go.id
DocumentRoot /var/www/html
</VirtualHost>
I have access IP 192.168.10.103 or two.example.go.id in server A it load perfectly. But when I access with two.example.go.id in other device (Internet), it doesn't work. This site can't be reached.
Is there a step I missed?
*This my first question with poor english. CMIIW
Did you also add a /etc/hosts to the Server B? Because /etc/hosts works only on the device you have added it on. For example, if you add a /etc/hosts directive in Server A, it will only work for Server A. You have to add the same for Server B also.
Or, if you don't want to use /etc/hosts because of this, then you can setup a DNS server of your own in your local network.
Related
sorry for my bad English, I'm gonna try to explain my problem.... I have to do a configuration of Apache for school. I want create a web server model with three host. I have three virtual machine on virtual box and each one can communicate with an internal network. Indeed three different apache server can be seen in each vm if I call it in browser.
Now I have to configure mod_proxy.
I want this configuration: the first vm is a server, responding a specifical domain, from this server I want to reach the other 2 apache from the other 2 different vm. Server localhost ip address 192.168.1.100 vm01 localhost/vm01 link to ip address 192.168.1.101 vm02 localhost/vm02 link to ip address 192.168.1.102
So, I spend few days in apache mod_proxy but I can't find a perfect guide or example.
I try to use this vhosts.conf in server, but didn't work. Please be patient I'm new in Apache.
<VirtualHost *:8080>
ServerName localhost
DocumentRoot /home/francesco/proxy/htdocs/
</VirtualHost>
<VirtualHost *:8080>
ServerAdmin webmaster#proxy.com
ServerName www.vm01.com
ProxyPass /vm01 http://192.168.1.101
ProxyPassReverse /vm01 http://192.168.1.101
</VirtualHost>
You have defined two Virtual Hosts on port 8080. Combine it to one.
<VirtualHost *:8080>
ServerAdmin webmaster#proxy.com
ServerName www.vm01.com
ProxyPreserveHost On
ProxyPass /vm01 http://192.168.1.101
ProxyPassReverse /vm01 http://192.168.1.101
</VirtualHost>
Is it possible to configure my URL which has my IP address on it- like: "http://192.168.xx.yy/index.php". The situation is when I run Apache server in my PC, and load localhost in it. I know it is possible after hosting with external server, but is there any way we can configure within our localhost?
How to configure the Apache files to make this happen? I tried in my localhost, editing the "httpd.conf" by adding this inside like this - please tell me where I am getting the issue!
ServerName localhost:80
HostnameLookups Off
<VirtualHost *:80>
# This first-listed virtual host is also the default for *:80
ServerName www.example.com
ServerAlias example.com
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName other.example.com
DocumentRoot /www/otherdomain
</VirtualHost>
DocumentRoot "c:/wamp/www/"
Yes, you can play with multiple IP addresses on your machine. Configuration depends on your OS. Article Create Multiple IP Addresses to One Single Network Interface is for linux.
But, better way is to use VirtualHosts based on host names or (simplest) on ports. So you can get http://siteA.mycoputer.localhost, http://siteB.mycomputer.localhost in the first case and http://192.168.x.y:8000, http://192.168.x.y:9000 in the second case
Here is Apache Server config example from Apache Server 2.2 documentation
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example.org
# Other directives here
</VirtualHost>
I'm looking to set up VirtualHosts on my apache server and was looking for documentation that would tell me if these 2 entries are identical
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName example1.com
</VirtualHost>
Notice the lack of www. in the second one.
Thanks
This is from the Apache docs (http://httpd.apache.org/docs/2.0/mod/core.html#servername):
The ServerName directive sets the hostname and port that the server uses to identify itself. This is used when creating redirection URLs. For example, if the name of the machine hosting the web server is simple.example.com, but the machine also has the DNS alias www.example.com and you wish the web server to be so identified, the following directive should be used:
ServerName www.example.com:80
So I guess they are not identical.
I am using my local machine as a development server. I have my hosts file set up as such:
127.0.0.1 localhost
127.0.0.1 cdog24
127.0.0.1 xxxxxorg
127.0.0.1 newintranet
My httpd-vhosts.conf file is set up as follows:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "D:\Webserver\htdocs"
ServerName localhost
ServerAlias localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\Webserver\htdocs\cdog24"
ServerName cdog24
ServerAlias cdog24
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\Webserver\htdocs\xxxxxorg"
ServerName xxxxxorg
ServerAlias xxxxxorg
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\Webserver\htdocs\newintranet"
ServerName newintranet
ServerAlias newintranet
</VirtualHost>
I am running xampp and can access each site on my local machine respectively by typing in:
http://localhost
http://cdog24
http://xxxxxorg
http://newintranet
When i go to a different computer on my network, I assume I have to type int he name of my machine or use the IP address. So, when I type in the following:
http://machinename/cdog24 or http://10.1.0.24/newintranet
I am taken to a 404 page.
What am I missing? Firewall on local machine or network do not factor as they are both off. I am on a Windows 7 local machine, the remote machine is also Windows 7.
Thanks for any help.
You will need to edit the hosts file on the remote machine (where the browser is running, not the server):
x.x.x.x cdog24
x.x.x.x xxxxxorg
x.x.x.x newintranet
Change x.x.x.x to the IP address of the Windows box that is running the server.
Now you should be able to browse to, say http://cdog24/ in your browser.
However, do NOT add a localhost entry that points to the other machine. localhost should always point to 127.0.0.1!
Have you tried with just http://machinename/ ?
http://machinename/directory would require that the document root be pointing to htdocs itself.
You need to work out what the IP address of your machine is on your network, and then edit teh hosts files on the other machines to point to yours
<your local IP> cdog24
<your local IP> xxxxxorg
<your local IP> newintranet
You maybe also have to update the apache conf file to work from your network address rather than 127.0.0.1.
I have wamp setup with quite a few websites setup as virtual hosts like this in httpd.conf
<VirtualHost 127.0.0.1>
ServerName project1.local
DocumentRoot "c:/wamp/project1/"
</VirtualHost>
I have these input in the wamp machine's host file and I can access them just fine on that machine.
127.0.0.1 project1.local
However, when I try to put an entry on my OSX machine as (192.168.1.101 being the internal ip of the wamp machine) it won't pull the page up.
192.168.1.101 project1.local
Is there something else I need to do to make this work from other machines? Thanks!
You either need <VirtualHost 192.168.1.101> (in addition to 127.0.0.1), or simply use <VirtualHost *> to put the VH on all addresses.
Just add below code in your virtual host config file
In the below code,
'Client_IP' is the IP of the machine from where you want to access the directory without using any ip on the address bar, just put severname in the address bar like 'servername/'.
<VirtualHost *:80>
ServerName servername
DocumentRoot d:\wamp\www\dir_name
<Directory "d:\wamp\www\dir_name">
Order Allow,Deny
Allow from 127.0.0.1 Client_IP
</Directory>
</VirtualHost>
Then, set same servername that you have used for the virtual host on apache server like,
server_ip servername
in the client machine c:/windows/system32/drivers/etc/hosts file.