How to host http(s)://intranet with ISPConfig?

Discussion in 'Installation/Configuration' started by cbj4074, Jul 29, 2015.

  1. cbj4074

    cbj4074 Member

    Hello!

    I know that I've asked this question before, but I cannot for the life of me find it! So, apologies in advance for that.

    I know that there are sound reasons for which a FQDN must be used when creating a domain in ISPConfig (the question has been asked many times, e.g., https://www.howtoforge.com/community/threads/short-name-for-intranet.62365/ ).

    Given the above, how might one host a website that should be accessible at http://intranet using ISPConfig?

    And, in fact, I have had this working correctly in the past (just yesterday, actually). But then we made some DNS changes, and even though we attempted to undo them, now requests for http://intranet are routed to the default NGINX virtual-host, and the oh-so-familiar "Welcome to nginx!" page is returned.

    With regard to DNS, we have two zones configured:

    1.) domain.tld

    Within this zone, we have a CNAME record that maps "intranet" to this machine's FQDN, which is something like "server4.domain.tld".

    2.) intranet.domain.tld

    Within this zone, we have the usual A records, and additionally A records for "" (blank) and * (wildcard), which point to this server's IP address.

    Ultimately, I'm not really sure how this was working correctly before yesterday, given that ISPConfig cannot be configured to service requests for non-FQDNs, like "intranet".

    Given that our DNS changes seem to have changed the web-server's behavior, despite attempting to undo them, I'm left wondering, "What is the way forward?"

    As a temporary measure, I enabled the default virtual-host in NGINX and added something like this to it:

    Code:
    location / {
       return 301 $scheme://intranet.domain.tld$request_uri;
    }
    
    This "solves" the problem for now, because requests for http://intranet are redirected to http://intranet.domain.tld, but we need for http://intranet to be retained in the browser's URL field in the longer term.

    Thanks for any help with this!
     
  2. cbj4074

    cbj4074 Member

    Aha! I figured it out. I'll articulate my findings in case anybody runs into this in the future (or more likely, I run into it again!).

    So, the problem was not with DNS at all; DNS is working correctly.

    Also, the ISPConfig configuration is irrelevant where this issue is concerned.

    The reason that this worked up until yesterday is that NGINX's default virtual-host was disabled, in which case NGINX was choosing the correct virtual-host, "intranet.domain.tld", (because it is first, alphabetically). Ultimately, http://intranet was retained in the browser's URL, and all was well.

    What changed yesterday was the LEMP stack configuration. In particular, we installed Zend Server on this machine, which upon installation creates the file /etc/nginx/conf.d/default.conf, which in turn includes the following:

    Code:
    server {
      listen  80;
      server_name  localhost;
    
      location / {
      include /etc/nginx/fastcgi.conf;
    
      root  /usr/share/nginx/html;
      index  index.html index.htm;
      }
    
      error_page  500 502 503 504  /50x.html;
      location = /50x.html {
      root  /usr/share/nginx/html;
      }
       
       include "/usr/local/zend/etc/sites.d/zend-default-vhost-80.conf";
    }
    
    This explains why we were all of a sudden seeing the default NGINX page instead of the first matching virtual-host in /etc/nginx/sites-enabled.

    The solution? Simply remove the file that Zend Server created, /etc/nginx/conf.d/default.conf and reload NGINX!

    :)
     

Share This Page