您的位置:首页 > 运维架构 > Nginx

nginx解决前端跨域配置

2017-09-13 12:18 190 查看


在nginx.conf文件中 添加如上配置:

  


在ajax中将原来的 url:http://192.168.1.127:8905/findItem 改成:'http://localhost/findItem'

 

  listen :80;  #监听host为localhost:80 的客户端请求

  server_name localhost;

  # pathname 为 /findItem 时 设置请求 http://192.168.1.127:8905/findItem
  location /findItem {
    add_header 'Access-Control-Allow-Origin' '*';
    proxy_pass http://192.168.1.127:8905/findItem;   }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: