generator-jhipster: Traefik issues, redirect login error
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'; - We can also configure traefik to serve the gateway application without context. (/) There may be consequences to doing that …
- change port by default expose in the configuration
- 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
- Checking this box is mandatory (this is just to show you read everything)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (12 by maintainers)
@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
@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.
@antarus if you modify the default ports, please have a look (and update if necessary) this new page: https://www.jhipster.tech/common-ports/
it’s not a problem with traefik. I’m sure this is the
login()method inlogin.service.tsthat does not work the same way as other services.