0
votes

Spring social adds wrong Location header when authenticating behind proxy

My setup consists of 3 docker images

  • Nginx
  • Spring boot application
  • Angular 5 application

Now when authenticating everything works fine until google authentication succeeds.

When google redirect to my page the request url is correct https://example.com/signin/google, but the Location header is http://backend-app:8080/social/signup and the browser tries to access the url in location header which fails because it's an internal url.

In configuration I set https://example.com as the application url

@Bean
public ProviderSignInController providerSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository, SignInAdapter signInAdapter) {
    ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, signInAdapter);
    providerSignInController.setSignUpUrl("/social/signup");
    providerSignInController.setApplicationUrl(environment.getProperty("application.be.url"));
    return providerSignInController;
}

But somehow the Location header is still the internal url. I'm not sure whether the issue is in nginx or back-end application, but I suspect the back-end application.

1

1 Answers

0
votes

Got it working by adding to my nginx.

location /signin {
    proxy_set_header Host example.com;
    proxy_pass http://backend-app:8080/signin;
}

location /social {
    proxy_set_header Host example.com;
    proxy_pass http://backend-app:8080/social;
}

I tried that previously, but maybe I did something else wrong then...