多个服务器块只有1个服务器块在移动中加载

时间:2017-01-31 18:10:53

标签: nginx dns virtualhost ubuntu-16.04

我在站点可用的nginx中创建服务器块。我有2个服务器名称它可以正常访问浏览器,但在移动它将显示IP地址,它将加载第一个应用程序,我无法加载我的第二个应用程序,因为如果我拨入url mysecondsubdomain.mydomain.com它将重定向到IP地址,第一个应用程序将服务..我不知道为什么它的行为像这样

更新:我在浏览器中注意到几个小时后我输入mysecondsubdomain.mydomain.com我将被重定向到i.p地址并且它将用于我的第一个应用程序

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;
    }
}  


 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;   
             }
     }

0 个答案:

没有答案