Generator-jhipster: Traefik issues, redirect login error

Created on 15 Oct 2018  路  15Comments  路  Source: jhipster/generator-jhipster

Overview of the issue

Hello,

[ ] 1. when we generate a gateway with keycloack and traefik we access the url of the gateway by http://localhost/GATEWAY_NAME/
but when we click on authenticate, we are redirected to
http://localhost/login
that does not exist.
[ ] 2. By default, traefik dashboard and gateway ports are in conflict (8080)
it does not pose a problem when we use containers but in development, I use only the container traefik, the application being launched via ./mvnw. the application refusing to launch if traefik is started via the generated configuration.
[ ] 3. If you access a gateway API without being authenticated, you are also redirected to localhost/login

Motivation for or Use Case

Authentication should be functional by default with traefik.

Reproduce the error

use the jdl configuration and make
jhipster import-jdl bug.jdl
build the image
./mvnw verify -Pprod dockerfile: build

create a docker folder
go to the docker folder and do
jhipster docker-compose
select the traefik option

once generation is complete, edit the traefik.yml file and change the default port of the dashboard, which conflicts with the gateway application's default port
replace
- 8080: 8080
by
- 18080: 8080
launch the necessary containers:
docker-compose -f keycloak.yml -f traefik.yml -f consul.yml up

return to the application folder, execute the command
. /mvnw

once the server has started go to the address:
http://localhost/gateway/

the application loads, then try to authenticate.
the application tries to redirect us to http://localhost/login 404 page not found`

Related issues
Suggest a Fix


    • I don't think it's great but it has the merit of working

      add the name of the application in the login.services.ts

      location.href = '//' + location.hostname + port + '/GATEWAY_NAME/login';

  1. We can also configure traefik to serve the gateway application without context. (/)
    There may be consequences to doing that ...
  2. change port by default expose in the configuration
  3. the suggest for 1 seem to not resolve this problem.
JHipster Version(s)

5.4.2

JHipster configuration

jdl
application {
config {
baseName gateway
applicationType gateway
authenticationType oauth2
serviceDiscoveryType consul
}
}

Browsers and Operating System

linux, windows
firefox, chrome, IE

  • [x] Checking this box is mandatory (this is just to show you read everything)

All 15 comments

maybe there is a link but with keycloak, I can access the page of the entity (after update the login.service.ts)but I can't login, hcouplet can log in but access is denied.
it would be necessary to see if hcouplet has the same anomaly with the 5.4.2 and UAA

We are trying to evaluate consul/traefik setup for microservice and seeing the same issue. After updating login.service.ts, I can login properly via keycloak and the redirects work fine.

My guess is that traefik can not properly handle redirect. Either we need to configure traefik differently or there is a bug in traefik. I just don't know traefik well. Maybe someone with good knowledge on traefik can help.

@antarus @fw060 can you please confirm what version of traefik you are using?
Did you test with last version 1.7.3?

@DanielFran I was using traefik 1.7.2 and I just tested against 1.7.3. I still see the same problem.

I was hoping the problem can be fix by going to traefix 1.7.x since there was a fix: https://github.com/containous/traefik/pull/3631. I am new to traefik, maybe this can be fixed by just updating traefik config?

it's not a problem with traefik.
I'm sure this is the login() method in login.service.ts that does not work the same way as other services.

i found a solution for point 1 and 3 i do a PR later ;)

@deepu105 do I have to change the default port of the traefik dashboard in this PR or do I do another one?

@antarus if you modify the default ports, please have a look (and update if necessary) this new page: https://www.jhipster.tech/common-ports/

@fw060 can you try my PR ?

@antarus I just tried your PR by modifying my generated project directly. The change works great with traefik (http://localhost/gateway/) AND without traefik when I expose the gateway directly (http://localhost:8081).

Thanks a lot for the quick fix. Please let me know if my test is enough or you want me to rebuild jhipster generater from your branch.

thanks.
The PR has been approved by mraible, there is nothing to do but wait for the merge :)

@antarus is this ticket still valid, I see there are some PRs merged which points to this, can we close this? next time please open separate issues or do everything in one PR so that we dont keep issues open for ever with partial fix

I asked if I had to do a PR or several...
All that remains is the documentation to be merged.

@antarus normally several PRs are better since its easy to review, but then its good to have one issue per PR so it can be closed automatically

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RizziCR picture RizziCR  路  3Comments

DanielFran picture DanielFran  路  3Comments

DanielFran picture DanielFran  路  3Comments

ahmedeldeeb25 picture ahmedeldeeb25  路  3Comments

SudharakaP picture SudharakaP  路  3Comments