Nginx Subdomains

Discussion in 'Installation/Configuration' started by sirchuck, Mar 12, 2014.

  1. sirchuck

    sirchuck New Member

    First I just wanted to say ISPConfig is great so far. Its a real timesaver.

    I am having a problem setting up subdomains, and multipul domains with the same name. Nginx keeps telling me under the sites-available that there was an error loading the subdomain file ISPConfig created.

    I can't find any info on it, anyone else having this issue?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    There is no issue known in that function. maybe you edited something in nginx config and this stopped the nginx config updates? ispconfig can not decide if a change that it has made himself or a change that was done manually in a config file caused nginx to fail, so it has to keep the last working config.
     
  3. sirchuck

    sirchuck New Member

    I typed rm 000-mysite * instead of rm 000-mysite.* to get rid of mysite and mysite.err :) Soo, I'll get back to you after I rebuild my server. haha.

    You have to love nub mistakes.
     
  4. sirchuck

    sirchuck New Member

    Ok, server back up and running , same issues with the subdomains though. nginx creates a .err file when it cant compile yourserver.com's site-available file on Ubuntu 13.04. Every time I tell ISPConfig 3 to create a subdomain, or a new site using the same domain it breaks. Right now basically im trying to create a chuck.mysite.com that will go to mysite.com/chuck and a newsite.mysite.com that will go to its own space. ISPConfig seems to be doing this right except it makes some mistake in the creation of the nginx file which i will copy past for you now.

    ******* Redirect to mysite.com/chuck
    server {
    listen *:80;


    server_name mysite.com chuck.mysite.com;

    root /var/www/mysite.com/web;



    index index.html index.htm index.php index.cgi index.pl index.xhtml;



    error_page 400 /error/400.html;
    error_page 401 /error/401.html;
    error_page 403 /error/403.html;
    error_page 404 /error/404.html;
    error_page 405 /error/405.html;
    error_page 500 /error/500.html;
    error_page 502 /error/502.html;
    error_page 503 /error/503.html;
    recursive_error_pages on;
    location = /error/400.html {

    internal;
    }
    location = /error/401.html {

    internal;
    }
    location = /error/403.html {

    internal;
    }
    location = /error/404.html {

    internal;
    }
    location = /error/405.html {

    internal;
    }
    location = /error/500.html {

    internal;
    }
    location = /error/502.html {

    internal;
    }
    location = /error/503.html {

    internal;
    }

    error_log /var/log/ispconfig/httpd/mysite.com/error.log;
    access_log /var/log/ispconfig/httpd/mysite.com/access.log combined;

    location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
    }

    location = /favicon.ico {
    log_not_found off;
    access_log off;
    }

    location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
    }

    location /stats {

    index index.html index.php;
    auth_basic "Members Only";
    auth_basic_user_file /var/www/clients/client0/web1/web/stats/.htpasswd_stats;
    }

    location ^~ /awstats-icon {
    alias /usr/share/awstats/icon;
    }

    location ~ \.php$ {
    try_files /aebb81e1ffa2e00a218d5d794e781a67.htm @php;
    }

    location @php {
    try_files $uri =404;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9010;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
    }


    }



    ******* test.mysite.com - new site not redirect

    server {
    listen *:80;


    server_name test.mysite.com ;

    root /var/www/test.mysite.com/web;



    index index.html index.htm index.php index.cgi index.pl index.xhtml;



    error_page 400 /error/400.html;
    error_page 401 /error/401.html;
    error_page 403 /error/403.html;
    error_page 404 /error/404.html;
    error_page 405 /error/405.html;
    error_page 500 /error/500.html;
    error_page 502 /error/502.html;
    error_page 503 /error/503.html;
    recursive_error_pages on;
    location = /error/400.html {

    internal;
    }
    location = /error/401.html {

    internal;
    }
    location = /error/403.html {

    internal;
    }
    location = /error/404.html {

    internal;
    }
    location = /error/405.html {

    internal;
    }
    location = /error/500.html {

    internal;
    }
    location = /error/502.html {

    internal;
    }
    location = /error/503.html {

    internal;
    }

    error_log /var/log/ispconfig/httpd/test.mysite.com/error.log;
    access_log /var/log/ispconfig/httpd/test.mysite.com/access.log combined;

    location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
    }

    location = /favicon.ico {
    log_not_found off;
    access_log off;
    }

    location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
    }

    location /stats {

    index index.html index.php;
    auth_basic "Members Only";
    auth_basic_user_file /var/www/clients/client0/web3/web/stats/.htpasswd_stats;
    }

    location ^~ /awstats-icon {
    alias /usr/share/awstats/icon;
    }

    location ~ \.php$ {
    try_files /268b4b0d27d610b8a50e55162a049289.htm @php;
    }

    location @php {
    try_files $uri =404;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9012;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
    }

    }

    Any ideas?
     
  5. sirchuck

    sirchuck New Member

    *** Update ****

    So I went in to my nginx config and enabled the
    Server_names_hash_bucket_size 64;
    and changed
    Server_name_in_redirect off
    to
    Server_name_in_redirect on

    Now everything seems to be working. I should note I installed a 64bit version of ubuntu, maybe that has something to do with it. The guide I followed did not mention having to change these config settings though.

    Thanks for your time, hope this helps someone else.
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    I guess your domain anmes are quite long, so they exceeded the default max. domain name size of nginx which is 64 chars.
     
  7. sirchuck

    sirchuck New Member

    Well that part did confuse me because the only domain names I used were, fixiwiki.com and test.fixiwiki.com and chuck.fixiwiki.com for subdomains.

    However I still got the error in my nginx error log saying i needed to move it to 64. Maybe ISPConfig registers a domain name longer than 32?

    My domain names should not be long enough to have to had done that.
    Any ideas?
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    ISPconfig is not doing more then writing the vhost file, so you can see in detal in that file, which settings are used.
     
  9. sirchuck

    sirchuck New Member

    Well I wanted to test to see if I commened out the server_names_hash_bucket_size 64 line if it would still work. It doesn't.

    In your nginx.conf file do you have a line that says:
    server_names_hash_bucket_size 32 ?
    or does it default to that?

    My file only had the 64 version, but it was commented out, maybe I could just change it to 32 im not sure. But I do know that not having the line at all makes it impossible to create subdomains with my setup.

    **** Update ** Testing the theory that maybe I just needed to assign a value of 32 to the line didnt work. So apparently it defaults to 32 and I really did need the 64 version. Weird.
     
    Last edited: Mar 13, 2014

Share This Page