在Listen ip:port; 这个指令行中,加参数default
这个server段就会是这个ip的默认站点
server {
listen 80 default;
server_name web.com ;
location / {
root F:/project/web;
index index.html index.htm index.php;
autoindex on;
}
location ~ .php$ {
root F:/project/web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 80 default;
server_name www.v2hi.top;
root /www/wwwroot;
location / {
index index.html index.htm index.php;
#autoindex on;
#添加下面一行,只能有一个值,不能多个值。只支持单域名和*,因为*不安全,所以当需要添加多域名的时候可以借助nginx的if语句来判断。
add_header Access-Control-Allow-Origin 'http://www.v2hi.top';
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#ssl on;
#ssl_certificate ssl/1_www.v2hi.top_bundle.crt;
#ssl_certificate_key ssl/2_www.v2hi.top.key;
}
原创文章,作者:维尼兔,如若转载,请注明出处:https://www.v2hi.top/?p=311