首页 > 解决方案 > Springboot 不会重定向到 nginx 上的论坛

问题描述

我在 Nginx 网络服务器上安装了一个论坛,并且我在同一台服务器上运行了 springboot,但我使用 nginx 作为代理,所以效果很好,问题是我在名为 forums 的 nginx 网站文件夹中安装了论坛,我添加了 / forums/ 到 spring boot security 但是当我去 url/forums/ 我得到一个 spring security 阻止我进入页面?

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.requiresChannel().anyRequest().requiresSecure();
        http.cors().and().csrf().disable();

        http
                .authorizeRequests()
                .antMatchers("/", "/rest", "/js/**", "/images/**", "/css/**", "/assets/**", "/login", "/register", "/font/**", "/fonts/**", "/sitemap.xml", "/hiscores", "/rest/players/get/**", "/rest/players/update/**",
                        "/rest/players/login/**", "/rest/**", "/pp/api/success", "/pay", "/pay/success", "/pay/cancel", "/classes", "/master/**", "/vendor/**", "/videos/**", "/img/**", "/forums/**", "/forums", "/download/", "/rest/version/", "/rest/changelog/").permitAll()
                .anyRequest().authenticated()
                .and()
                .logout().logoutRequestMatcher(new AntPathRequestMatcher("/dashboard/logout")).logoutSuccessUrl("/");
    }

它应该允许我去 /forums/ 的 url

编辑:

Path    /forums
Error   Not Found
Status  404
Message No message available

论坛控制器

@RestController
public class ForumsController {
    @RequestMapping(value = "/forums/", method = RequestMethod.GET)
    public ModelAndView showDashboard(ModelAndView modelAndView) {
        modelAndView.setViewName("redirect:/forums");
        return modelAndView;
    }
}

标签: javaspring-bootspring-mvcspring-security

解决方案


推荐阅读