Subdomain and nginx

I have something to ask, I have account in go daddy and we have register the main domain in go daddy…now I also purchase in GCE google cloud computing engine…and I host all my web application…I set subdomain in go daddy the DNS and pointing to the i.p address of my GCE, in my GCE i set up server-block or equivalent to virtual host…my problem is that when I access it on mobile the subdomain it will not hit the page or the subdomain I want to load…it always the first subdomain, instead I hit the secondsubdomain. also it will display i.p adress intead subdomain name. why it alwasy i.p adress if I viewed in mobile…sometimes in desktop too.

here is my configuration nginx.

firstsubdomain

   server {
        listen 80 ;
        

        root /var/www/project1/public/;
        index index.php index.html index.htm;
        server_name firstproj.mydomain.com;

location / {

     try_files $uri $uri/ /index.php?$query_string;
}


location ~ \.php$ {
     try_files $uri /index.php =404;
     fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;    
     fastcgi_index index.php;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     include fastcgi_params;
    }
}

second subdomain

 server {
        listen 80 ;
        

        root /var/www/project2/public/;
        index index.php index.html index.htm;
        server_name secondproj.mydomain.com;

location / {

     try_files $uri $uri/ /index.php?$query_string;
}


location ~ \.php$ {
     try_files $uri /index.php =404;
     fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;    
     fastcgi_index index.php;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     include fastcgi_params;
    }
}

Do you have the sim links in the sites-enabled folder? Also, maybe you can try placing all of them in a single file - default (which is already there) and restart nginx.

Let me know what happens.

Your config files looks normal for me, no obvious mistakes here.

Did you tried to disable first domain temporarily and check if second will work w/o issues after that?
Is there everything ok with DNS records?

I already tried all your suggestion guys but no luck,… I also tried to create only 1 server block it works fine it load the page, now the problem I am facing is that I see the the ugly i.p address of my gce if I viewed it on my mobile. What I want is the name of the subdomain not the I.P address I don’t know why always I.P address is being shown if mobile.

Thank you in advance

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.