nginx跨域设置
2019獨角獸企業重金招聘Python工程師標準>>>
nginx跨域設置 博客分類: javanginx跨域問題
例子:訪問http://10.0.0.10/ 需要能實現跨域
操作:
http://10.0.0.10/項目是部署在tomcat里面,tomcat跨域暫時還不會,按照網上的方法操作也沒成功
只有用Nginx做個代理,解決跨域問題了!
1、將www.tangxiaoyue.com域名指向http://10.0.0.11/。只有在域名上設置才能實現跨域。(10.0.0.11是Nginx的IP)
2、在nginx上的配置文件tang.conf進行設置
配置文件例如:
server { listen 80; server_name tangxiaoyue.com; if ( $http_user_agent = "Mozilla/5.0"){ return 403; } location / { add_header 'Access-Control-Allow-Origin' '*'; # # Om nom nom cookies # add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; # # Custom headers and headers various browsers *should* be OK with but aren't # add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; proxy_pass http://10.0.0.10/; proxy_set_header Host "tangxiaoyue"; } } http://www.cnblogs.com/brucetang/p/6093075.html轉載于:https://my.oschina.net/xiaominmin/blog/1598352
總結
- 上一篇: docker WARNING: IPv4
- 下一篇: dubbo管控台安装