nginx vhosts configuration problem
迷茫
迷茫 2017-06-17 09:17:13
0
2
736

My two domain names are pointed to the server
The first www.xxx.cn
The second api.xxx.cn

I pointed the api to a directory and configured api.xxx.cn.conf so that it can be accessed normally.

Then I visit www.xxx.cn and it also points to the api.xxx.cn directory I configured.

There are only two files in the vhosts directory
One is api.xxx.cn.conf
and the other is localhost.conf

If www.xxx.cn is not configured, it should point to the root directory of the default configuration. Why does it also point to api

api.xxx.cn.conf configuration details


  1 server {
  2         listen       80;
  3         server_name  api.xxx.cn;
  4         root   "/www/Hphp/Public/";
  5 
  6         location / {
  7             #root   html;
  8             index  index.html index.htm  index.php;
  9             #autoindex  on;
 10             if (-f $request_filename) {
 11                 break;
 12             }
 13             if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") {
 14                 break;
 15             }
 16             if (!-e $request_filename) {
 17                 rewrite ^/(.*) /index.php/ last;
 18             }
 19         }
 20 
 21         location ~ \.php(.*)$ {
 22             fastcgi_pass   127.0.0.1:9000;
 23             fastcgi_index  index.php;
 24             fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
 25             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
 26             fastcgi_param  PATH_INFO  $fastcgi_path_info;
 27             fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
 28             include        fastcgi_params;
 29         }
 30 }

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
小葫芦

Because your domain name resolves to the same place. You can configure a default IP binding to block it.

阿神

You can configure to prohibit empty host access

server {
    server_name _;//标识空主机
    return 500;//返回500错误
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!