通过nginx代理Nexus 因为CSP导致js运出问题

今天在建立Nexus私有lib服务器的时候,nexus默认启动8081端口,并且使用jetty启动,现在想通过nginx代理出去,在进行过程中碰到两个问题 一,代理后,对于nexus 的css,js文件还是 http://开头...

今天在建立Nexus私有lib服务器的时候,nexus默认启动8081端口,并且使用jetty启动,现在想通过nginx代理出去,在进行过程中碰到两个问题

一,代理后,对于nexus 的css,js文件还是 http://开头,导致这些js ,css加载有问题。 这个问题在nginx上有两种解决方法

1,nginx中 add_header Content-Security-Policy "upgrade-insecure-requests;default-src"

2,代理块使用指令: proxy_set_header X-Forwarded-Proto https;


二,Content-Security-Policy 配置不当,导致 js的匿名函数和inline函数报错,页面跳转不了,一直在initiazing见下图:

attachments-2020-05-nddeQgwq5ebe4e32da1f3,png


解决此问题,需要修改CSP的策略,加上 unsafe-inline 和unsafe-eval ,配置见如下:

add_header Content-Security-Policy "default-src 'self' 'unsafe-inline' 'unsafe-eval'" ;

有关CSP相关内容见:

https://wenda.zuncuang.com/article/490


  • 发表于 2020-05-15 16:12
  • 阅读 ( 63 )

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
shitian
shitian

662 篇文章

作家榜 »

  1. shitian 662 文章
  2. 石天 437 文章
  3. 每天惠23 33 文章
  4. 小A 29 文章