1. 首页
  2. 未分类

在nginx中配置ip直接访问的默认站点

在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.v2v0.com;
        root   /www/wwwroot;
        location / {
            index  index.html index.htm index.php;
            #autoindex  on;
            #添加下面一行,只能有一个值,不能多个值。只支持单域名和*,因为*不安全,所以当需要添加多域名的时候可以借助nginx的if语句来判断。
            add_header Access-Control-Allow-Origin 'http://www.v2v0.com';
        }
        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.v2v0.com_bundle.crt;
        #ssl_certificate_key ssl/2_www.v2v0.com.key;
}

原创文章,作者:维尼兔,如若转载,请注明出处:https://www.v2v0.com/?p=311

发表评论

邮箱地址不会被公开。 必填项已用*标注

联系我们

 

工作时间:周一至周五,09:30-17:00,节假日休息