【问题标题】:How to remove webapp name from urls in spring security如何在 Spring Security 中从 url 中删除 webapp 名称
【发布时间】:2019-08-11 04:26:24
【问题描述】:

我将我的 spring boot webapp 部署到 Apache Tomcat。 Apache Tomcat 位于 httpd 网络服务器后面。我想使用www.mydomain.de 访问我的网络应用程序,这在大多数情况下都可以正常工作。我通过使用具有以下配置的 VirtualHost 实现了这一点:

ProxyPass / ajp://localhost:8011/mywebapp/
ProxyPassReverse / ajp://localhost:8011/mywebapp/

webapp 运行良好,以至于我添加了 Spring Security 身份验证。当我单击需要身份验证的页面时,会加载 www.mydomain.de/mywebapp/login。我要www.mydomain.de/login

这是我的 Spring Security 配置:

@Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .antMatchers("/", "/index").permitAll()
                .anyRequest().authenticated()
                .and()
                .formLogin()
                .loginProcessingUrl("/j_spring_security_check")
                .loginPage("/login")
                .defaultSuccessUrl("/")
                .failureUrl("/login")
                .usernameParameter("username")//
                .passwordParameter("password")
                .permitAll()
                .and()
                .logout()
                .logoutUrl("/logout")
                .invalidateHttpSession(true)
                .permitAll();
    }

如何删除 URL 中的 webapp 名称?

谢谢!

【问题讨论】:

标签: spring apache spring-boot spring-security tomcat9


【解决方案1】:

您可以在 application.properties 文件中设置上下文路径。示例server.contextPath=/

【讨论】:

    猜你喜欢
    • 2014-07-12
    • 2016-07-24
    • 2018-04-11
    • 2020-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多