I have a spring boot app thats use keycloak adapter for authorization. My spring security file looks like this:
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
String roles = String.join(",", authConfig.roles());
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/vaadinServlet/UIDL/**").permitAll()
.antMatchers("/vaadinServlet/HEARTBEAT/**").permitAll()
.antMatchers("/")
.hasAnyRole(roles)
.anyRequest()
.permitAll()
.and().exceptionHandling().accessDeniedHandler(accessDeniedHandler())
.and().logout().logoutUrl("/logout")
.logoutSuccessHandler(new KyecloakLogoutSuccessHandler())
.deleteCookies("auth_code", "OAuth_Token_Request_State", "JSESSIONID")
.clearAuthentication(true)
.invalidateHttpSession(true)
.permitAll();
}
To integrate with keycloak I am using application.yml:
server:
port: "8081"
forward-headers-strategy: framework
keycloak:
auth-server-url: "http://127.0.0.1:8180/keycloak"
realm: "MyRelam"
resource: "MyClient"
publicClient: true
proxy-url: "http://127.0.0.1/keycloak"
So, my app run on port 8081 which connect to keycloak on port 8180 with relative-path=/keycloak. Also i run my app with server.servlet.context-path=/gui I try to configure nginx on port 80, because its only one port which others users can access to.
server {
listen 80;
server_name 127.0.0.1;
root D:/webreport/static;
set $onMaintanence false;
location / {
return 301 http://$host:80/gui;
}
location /gui/ {
if ($onMaintanence = "true") {
return 503;
}
error_page 503 502 @maintenance;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
proxy_pass http://127.0.0.1:8081;
}
location /keycloak/ {
proxy_pass http://$host:8180;
}
But keycloak still redierct me to login page on port 8180, and to port 8081 after success logining. How can I configure my nginx, app or keycloak maybe so it can be able to users on port 80?