使用nginx动静分离后,druid被拦截的解决方法
生活随笔
收集整理的這篇文章主要介紹了
使用nginx动静分离后,druid被拦截的解决方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
配置如下
#放行api文檔相關location doc.html {proxy_pass http://project;proxy_intercept_errors on; error_page 404 502 = /custom_error.html;}location ~ /webjars/.*\.(html|htm|woff|ttf|svg|eot|gif|jpg|jpeg|bmp|png|ico|txt|js|css|xml)$ {proxy_pass http://project;proxy_redirect off;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Real-IP $remote_addr;proxy_set_header Host $http_host;proxy_http_version 1.1;proxy_set_header Connection "";}#放行druid監控相關location ~ /druid/.*\.(html|htm|woff|ttf|svg|eot|gif|jpg|jpeg|bmp|png|ico|txt|js|css|xml)$ {proxy_pass http://project;proxy_redirect off;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Real-IP $remote_addr;proxy_set_header Host $http_host;proxy_http_version 1.1;proxy_set_header Connection "";}#最后攔截靜態資源,一定要放在最后,不然會攔截druid的監控和api接口location ~ \.(|gif|jpg|jpeg|bmp|png|ico|js|css)$ {root /etc/nginx/static;expires 1d; #使用expires緩存模塊,緩存到客戶端30天}總結
以上是生活随笔為你收集整理的使用nginx动静分离后,druid被拦截的解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AI案例精选
- 下一篇: 5G对全球经济的影响:中国报告