enable website on public domain and local ip

Discussion in 'Server Operation' started by Poliman, Aug 6, 2018.

  1. Poliman

    Poliman Member

    I would like to enable example.com for public IP [from outside of lan] of the server but in local network I would like to set to this website works under local IP of the server. Currently my vhost file looks like this:
    <VirtualHost *:80>
            ServerName example.com
            ServerAlias www.example.com
            ServerAdmin [email protected]
            DocumentRoot /var/www/example/public
            <Directory /var/www/example/public>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride All
                    Require all granted
    I tried change first line of above to <VirtualHost public_ip:80> but after reload apache it does not work. I also tried create parallel vhost with this same settings as above but with <VirtualHost> but it also does not work. Currently only set in web browser domain name example.com is opening website. Earlier, when vhost didn't contain ServerName and ServerAlias, website was visible under public IP and local IP (servr has two NICs). Could anybody help?
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Since it worked before, why not use it that way?
    Set up internal name service to return the internal IP, and public name service to return the IP reachable from the Internet. Check Apache listens to both interfaces.
    Poliman likes this.
  3. Poliman

    Poliman Member

    Thank you. I hit on it soon after create this thread.

Share This Page