1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Forward to another server based on subdomain

Discussion in 'Apache' started by unique24, Jun 11, 2018.

  1. #1
    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)

    1. is this possible, or because of the port forwarding I loss the subdomain info?
    2. and could server 1 forward the request to server 2?
    On both is Apache under Ubuntu Server 16.04

    Thank you
     
    unique24, Jun 11, 2018 IP
  2. pavv

    pavv Well-Known Member

    Messages:
    275
    Likes Received:
    8
    Best Answers:
    3
    Trophy Points:
    120
    #2
    Deleted.
     
    pavv, Jun 11, 2018 IP
  3. Cameron Fillers

    Cameron Fillers Member

    Messages:
    33
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    33
    #3
    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.
     
    Cameron Fillers, Jun 18, 2018 IP
  4. hostechsupport

    hostechsupport Well-Known Member

    Messages:
    413
    Likes Received:
    23
    Best Answers:
    7
    Trophy Points:
    138
    #4
    You may have to use Proxy directives in virtual host configuration to forward requests to other Server.
     
    hostechsupport, Aug 3, 2018 IP