Nginx

#静态资源服务

upstream static_server_pool{

  server  192.168.11.11:1001  weight=10

}

map $http_origin $origin_list{
    default http://www.haha.com;
    "~http://www.haha.com" http://www.haha.com;
    "~http://www.hehe.com" http://www.hehe.com;
}

server{

  listen  1002;

  server_name  www.haha.com;

  ssi  on;

  ssi_silent_errors  on;

  localtion / {

    alias  F:/haha/前端代码文件夹根目录/

    index  index.html;

  }

  location /static/stat/ {

    proxy_pass   http://static_server_pool;

  }

  localtion /static/js/ {

    alias  F:/haha/前端代码文件夹根目录/js/;

  }

  localtion /static/plugins/ {

    alias  F:/haha/前端代码文件夹根目录/plugins/;

    #允许跨域访问的外语地址,如果允许任何站点跨域访问则设置*,不建议

    add_header Access‐Control‐Allow‐Origin  $origin_list;        

    add_header Access-Control-Allow-Credentials  true;#允许客户端携带证书访问

    add_header Access-Control-Allow-Methods  GET;#允许客户端跨域访问的方法

  }

}

posted @ 2019-12-19 15:33  袋子里的袋鼠  阅读(85)  评论(0)    收藏  举报