If you like DNray Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

Two domain names on the same IP

Started by Sedfinder, Jan 30, 2023, 04:30 AM

Previous topic - Next topic

SedfinderTopic starter

I have set up virtual hosts on my Ubuntu server and everything is functioning properly. Each virtual host is displaying pages from its own directory. On an external machine, I executed the command "sudo nano /etc/hosts" and added "82.143.280.70 site1.server www.site1.server", with the IP being a fictional one. However, when I tried to access the virtual host in the browser, the default Apache page appeared instead.

What additional steps must I take to display the desired virtual host? It is worth mentioning that I am the only one who can access it as it is meant for testing and development purposes only. Once testing is done, I will attach the domain to the server but currently, there is no need to do so.
  •  


icellular01

To ensure that Apache responds correctly to your ARP requests, it is necessary to create a virtual host configuration. For Ubuntu users, there are sites-available sites-enabled folders where you can create the configuration in sites-available and activate it via a2ensite.

Similarly, for other Linux or Unix users, one must create a VirtualHost and restart Apache. If a default page shows up, then it suggests that the VirtualHost is misconfigured. In the sites-enabled folder, links to virtual hosts should exist. If they don't, create them through a2ensite and restart Apache.
  •  

timbarnard

It is unclear. For instance, on my host computer, I specify in the hosts file that my server with IP 192.168.0.11 has the addresses PHONE1 and PHONE2, and the server will respond to both as I have physically registered it from the host from where I am making the request.
After this, I have to instruct the server, in this case Apache, to respond correctly if asked for such an address. To do this, I need to check whether virtual hosts are enabled or not. It is unacceptable for the virtual hosts to work on the server but not on the computer. The issue could be that Apache is not receiving the correct request or not looking at VirtualHost.
  •  

ArinaThoggy

This is how I approached the problem:
1. Created a separate zone file and included it in named.conf.
2. In the zone file, I configured SOA and other necessary settings while specifying ns from aaa.com.
3. Added A record 111.111.111.111 to the www zone file (which corresponds to the IP of www.aaa.com).

Although everything seemed to work initially, some problems arose:
1. The pop3 server began to request a password file from bbb.com, which was resolved using 'ln -s'.
2. Exim started experiencing issues.
3. The internal Windows grid, which distributes DHCP addresses and settings, started functioning abnormally. Specifically, it was not visible in the network overview of the list of computers, but typing \\comp worked. This issue clearly pertains to DNS.

P.S. Could you provide me with a sample working configuration? Or at least provide some hints on what I may have done wrong?
  •  

kutteprovel

When you added the entry to the /etc/hosts file on the external machine, you're essentially telling the machine to resolve the hostname site1.server and www.site1.server to the IP address 82.143.280.70. However, this doesn't necessarily mean that the Apache server on your Ubuntu machine will know which virtual host to serve.

To fix this issue, you need to configure Apache to use the correct virtual host configuration file when a request is made from the external machine. Here are a few additional steps you can take:

Check the Apache configuration files: Make sure that the Apache configuration files on your Ubuntu machine are correctly configured to serve the virtual hosts. You can check the configuration files in the /etc/apache2/sites-available directory. Look for the configuration file that corresponds to the virtual host you want to access, e.g. site1.server.conf.
Check the ServerName and ServerAlias directives: In the virtual host configuration file, make sure that the ServerName and ServerAlias directives are correctly set. The ServerName directive should match the hostname you added to the /etc/hosts file on the external machine, e.g. site1.server. The ServerAlias directive should include any additional hostnames you want to serve, e.g. www.site1.server.

Check the dоcumentRoot directive: Make sure that the dоcumentRoot directive is correctly set to the directory that contains the files for the virtual host.
Restart Apache: After making any changes to the Apache configuration files, you need to restart Apache for the changes to take effect. You can do this by running the command sudo service apache2 restart on your Ubuntu machine.

Test the virtual host: Once you've made the changes and restarted Apache, try accessing the virtual host from the external machine again. You should now see the correct virtual host page instead of the default Apache page.
Нou can try using the curl command to test the virtual host from the command line. For example, you can run the command curl -H "Host: site1.server" http://82.143.280.70 to test the virtual host. This will send a request to the Apache server with the Host header set to site1.server, which should trigger the correct virtual host configuration.
  •  


If you like DNray forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...