排除法

先排除 是 jar 包 配置问题

  1. wget http://127.0.0.1:8085/manage/profile/upload/2021/07/05/8bd8d97f-e4b9-467e-a020-c6da4b98ddff.png

image.png

nginx 配置

  1. # 如果nginx有这个删除
  2. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  3. {
  4. expires 30d;
  5. error_log off;
  6. access_log off;
  7. }

完整 nginx 配置

  1. server
  2. {
  3. listen 80;
  4. server_name zh.demo.com;
  5. index index.php index.html index.htm default.php default.htm default.html;
  6. root /www/wwwroot/zh.demo.com;
  7. #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
  8. #error_page 404/404.html;
  9. #SSL-END
  10. #ERROR-PAGE-START 错误页配置,可以注释、删除或修改
  11. error_page 404 /404.html;
  12. error_page 502 /502.html;
  13. #ERROR-PAGE-END
  14. #PROXY-START
  15. location ~ /purge(/.*) {
  16. proxy_cache_purge cache_one $host$request_uri$is_args$args;
  17. #access_log /www/wwwlogs/zh.demo.com_purge_cache.log;
  18. }
  19. location /
  20. {
  21. if ( !-e $request_filename)
  22. {
  23. proxy_pass http://127.0.0.1:8922;
  24. }
  25. }
  26. #PROXY-END
  27. #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
  28. include /www/server/panel/vhost/rewrite/zh.demo.com.conf;
  29. #REWRITE-END
  30. #禁止访问的文件或目录
  31. location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md|\.jar)
  32. {
  33. return 404;
  34. }
  35. #一键申请SSL证书验证目录相关设置
  36. location ~ \.well-known{
  37. allow all;
  38. }
  39. access_log /www/wwwlogs/zh.demo.com.log;
  40. error_log /www/wwwlogs/zh.demo.com.error.log;
  41. }

springboot资源配置

  1. import org.springframework.beans.factory.annotation.Autowired;
  2. import org.springframework.context.annotation.Bean;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.web.cors.CorsConfiguration;
  5. import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
  6. import org.springframework.web.filter.CorsFilter;
  7. import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
  8. import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
  9. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  10. /**
  11. * 通用配置
  12. *
  13. * @author admin
  14. */
  15. @Configuration
  16. public class ResourcesConfig implements WebMvcConfigurer
  17. {
  18. @Autowired
  19. private RepeatSubmitInterceptor repeatSubmitInterceptor;
  20. @Override
  21. public void addResourceHandlers(ResourceHandlerRegistry registry)
  22. {
  23. /** 本地文件上传路径 */
  24. registry.addResourceHandler("/profile/**").addResourceLocations("file:/usr/local/upload/demo/" );
  25. }
  26. }