Hello, when I type in the browser: portal.company.com ... DNS is my own of my house (static IP) and port forwarding of port 80 forward the request to server 1 BUT when I type in the browser: files.company.com ... IP address is the same as above , portforwarding again 80 ... but the apache Server of server 1 should forward all request (from files.company.com) to server 2. Because: portal.company.com should be server 1 (IP x.x.x.x) files.company.com should be server 2 (IP same: x.x.x.x) is this possible, or because of the port forwarding I loss the subdomain info? and could server 1 forward the request to server 2? On both is Apache under Ubuntu Server 16.04 Thank you
You are going to want to inspect your apache configuration settings. You are looking for the option, "NameVirtualHost" and make sure that that is enabled, and enabled for port 80. Port forwarding for your home computer should be fine, since port forwarding is not converting the traffic to the ip address. You would run into issues if you had a proxy setup, and the proxy was redirecting the traffic to an ip address. As it stands, it sounds like you may not have namevirtualhost enabled, or you do not have a separate configuration for both subdomains, and that you might have a "catch all" account, which is broad enough that all traffic is being caught by it. My recommendation is to setup a config in your conf.d folder, and create two files, with 2 very basic configs, i.e. <VirtualHost *:80> RequestHeader unset Set-Cookie DocumentRoot /var/www/html/portal.company.com/ ServerName portal.company.com ServerAlias portal.company.com ErrorLog /var/log/httpd/portal.company.com_error_log </VirtualHost> and <VirtualHost *:80> RequestHeader unset Set-Cookie DocumentRoot /var/www/html/files.company.com/ ServerName files.company.com ServerAlias files.company.com ErrorLog /var/log/httpd/files.company.com_error_log </VirtualHost> make sure those two directories exist, and add an index.html file to each directory, simply with the site name inside of the file. Restart apache2, and try to hit those sites and see if they resolve. Best thing to do when you are having configuration issues is to do baby steps, and build off of a working configuration.
You may have to use Proxy directives in virtual host configuration to forward requests to other Server.