0

I have live server GCE (google cloud computing engine) and I created server block or virtual host, I created also DNS subdomain to my go daddy account and point to the i.p address of my GCE.I am new in nginx and I would like to know if we create multiple server block is this can be view on mobile also ...I tried to view in my mobile but only the first virtual host is always viewed...also if I will not edit my host file in my desktop if I will access my site or all my subdomain . it will abnormally display instead of secondsubdomain.mymaindomain.com the page will display is my firstsubdomain and it will display the i.p address Not firstsubdomain.mymaindomain.com.. can someone help me please what is missing in my configuration. I have created 2 virtual-host in /etc/nginx/sites-available/ . It's been 3 weeks for me to figure out and searching some help but no luck. I hope someone will help me.

banking.mydomain.com

server {
 listen 80 default_server;
 listen [::]:80 default_server;

 root /var/www/banking/public/;
 index index.php index.html index.htm;
 server_name banking.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;
    }
}  

inventory.mydomain.com

 server {
          listen 80;
          listen [::]:80;

      root /var/www/inventory/public/;

      index index.php index.html index.htm;

      server_name inventory.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;   
         }
 }

Thank you in advance.

Sunny J
  • 607
  • 3
  • 14
jemz
  • 109
  • 7
  • Location blocks don't care what the client is, desktop, mobile, fridge, etc. You could change default_server to the other block and see what happens. Are you sure that it's hitting the first server block, or could it be that given your proxy pass of php to the same PHP location that your PHP application is returning the wrong content? Please edit your question to a) Format your config file so it's easier to read b) Include curl showing request and response and that it's incorrect c) Applicable Nginx log files entries (access/error) and d) Maybe PHP logs showing it's serving the correct data. – Tim Feb 09 '17 at 03:13
  • Hi @Tim, I am new on this nginx, that is exactly the content of my configuration.I don't know what are other needed...I forgot to mentioned that I have go daddy account I set up dns subdomain and point it to i.p address of my GCE..please see my edit question – jemz Feb 09 '17 at 03:51
  • Your Nginx configuration looks ok, I think the problem is elsewhere. If you can work out how to provide the requested information you may get more help, but if you don't understand my request you're going to need to hire someone to help you. There are plenty of tutorials around on basics. – Tim Feb 09 '17 at 04:12
  • @Tim, I'll be glad if you can share some resources where I can learn about your request. – jemz Feb 09 '17 at 04:57
  • @Tim, you mean accessing my site using curl via command prompt ? – jemz Feb 09 '17 at 05:15
  • @Tim , can I ask you said that "Location blocks don't care what the client is", but in mobile we cannot edit the host file..how does mobile can access the subdomain if we can't edit the host file? – jemz Feb 09 '17 at 06:32
  • Hosts file is just a local version of DNS. Based on your questions I think you need to hire someone to help you, they're more basic than the questions an ICT professional would ask. – Tim Feb 09 '17 at 06:40

0 Answers0