Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with resource resolution in SBA 2.1.0 having server.servlet.context-path set #990

Closed
dickerpulli opened this issue Nov 5, 2018 · 17 comments

Comments

@dickerpulli
Copy link
Member

With having server.servlet.context-path set the resource resolution doesn't work property with SBA 2.1.0 wich results in a currupted login-page and a white page after login.

This problem only occurs when I set server.servlet.context-path. After deleting this property everythings works fine.

grafik

@joshiste
Copy link
Collaborator

joshiste commented Nov 5, 2018

Just for local development (using npm run watch)?

@joshiste joshiste added the bug label Nov 5, 2018
@joshiste joshiste added this to the 2.1.1 milestone Nov 5, 2018
@dickerpulli
Copy link
Member Author

No, also in staging environment.

@dejan-mladenovski
Copy link

dejan-mladenovski commented Nov 5, 2018

I also have the same problem on staging environment as @dickerpulli .

With version 2.0.4 and defined a server.servlet.context-path=/demo-adminserver the generated base href was <base href="/demo-adminserver/" /> and all assets, css and js files were defined as for example <link="assets/css/sba-core.css" .. /> which will pull the resource from http://hostname/demo-adminserver/assets/css/sba-core.css. Now, the generated HTML template is <base href="" /> and all static resources start with /, which will pull the resources from http://hostname/assets/css/sba-core.css completely ignoring the context path.

@wtatum
Copy link

wtatum commented Nov 5, 2018

Seeing the same behavior with the (equivalent?) configuration option spring.boot.admin.contextPath. The index page (and presumably API) resolve from the specified context path (i.e. /sba) but the UI loads static assets using host relative paths instead of including the context path, causing the blank white page and lots of errors on the console.

GET http://localhost:8080/assets/js/chunk-common.82a7af35.js net::ERR_ABORTED
sba:1 GET http://localhost:8080/assets/js/chunk-vendors.1df687d0.js net::ERR_ABORTED
sba:1 GET http://localhost:8080/assets/css/chunk-common.9808b72e.css net::ERR_ABORTED
sba:1 GET http://localhost:8080/assets/css/sba-core.360886fb.css net::ERR_ABORTED
sba:1 GET http://localhost:8080/assets/js/sba-core.7dfee25c.js net::ERR_ABORTED
sba:9 GET http://localhost:8080/assets/js/chunk-vendors.1df687d0.js net::ERR_ABORTED
sba:9 GET http://localhost:8080/assets/js/chunk-common.82a7af35.js net::ERR_ABORTED
sba:9 GET http://localhost:8080/assets/js/sba-core.7dfee25c.js net::ERR_ABORTED

@dheid
Copy link

dheid commented Nov 5, 2018

👍

@membersound
Copy link

Some for me. This is critical, because usually one would deploy the admin ui to a tomcat webserver, where the servlet path is derived from the application filename.

So if you deploy a my-admin.war file, the location will be http://yourserver:8080/my-admin.
If only run locally with embedded tomcat, this can be simulated with setting server.servlet.context-path=/my-admin. Note that any server.* settings only apply to embedded tomcat!

In this case, as others mentioned already, spring-admin will still try to resolve the assets from localhost:8080/assets/... even if server.servlet.context-path is set!

@joshiste
Copy link
Collaborator

joshiste commented Nov 7, 2018

Some for me. This is critical, because usually one would deploy the admin ui to a tomcat webserver, where the servlet path is derived from the application filename

I've currently very limited time to do a fix. You can stick to the 2.0.x server until then - the api for sba-client/-server is up- and downwards compatible

@wtatum
Copy link

wtatum commented Nov 7, 2018

Not sure about GP. For us, upgrading was important because the 2.0.4 client wasn't playing nice in a Spring Boot 2.1.0 application. That said, I never did much testing with 2.1.0 client and 2.0.4 server. Sounds like that would be a good option to look at.

@membersound
Copy link

I can confirm the 2.1.0 client works with 2.0.4 server. thanks!

@dickerpulli
Copy link
Member Author

Fix provided at #997

@dotpanic
Copy link
Contributor

dotpanic commented Nov 12, 2018

The fix in 2.1.1 is not working on my side. With the following configuration:

image

The base href is generated as followed:

image

Client and server have been updated to v2.1.1

@joshiste
Copy link
Collaborator

joshiste commented Nov 12, 2018

@dotpanic Could you post a project to reproduce? A quick test (using cli parameters did work for me)

@dotpanic
Copy link
Contributor

dotpanic commented Nov 12, 2018

I'm sorry, the previous error was on my side (wrong docker container deployment).

The href is now filled with a base URL:

<base href="http://xxx.com/sba/">

But I now get some Mixed Content errors in browser:

image

The main page is served via HTTPS and so the base href should be set to:

<base href="https://xxx.com/sba/">

I can't understand if it's a Spring Boot or Spring Boot Admin issue.

Here is my server configuration;

server:
  port: 4040
spring:
  security:
    user:
      name: admin
      password: secret
  output:
    ansi:
      enabled: never
  boot:
    admin:
      context-path: /sba

# Spring Actuator
management:
  server:
    port: 9002
    address: localhost
  endpoints:
    web:
      exposure:
        include: "*"
      base-path: /sba/actuator
    enabled: true
    logfile:
      external-file: log/current-instance.log
    health:
      show-details: always

My SBA is served behind a reverse proxy, nginx being in charge of SSL implementation:

Browser ---https---> nginx ---http---> SBA

@joshiste
Copy link
Collaborator

@dotpanic when running behind a proxy make sure the forward headers are set and taken into account. See https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-use-tomcat-behind-a-proxy-server
This should fix the wrong scheme in the URL

@dotpanic
Copy link
Contributor

@joshiste setting server.use-forward-headers to true did the trick! Thank you! :)

@bigfoot00
Copy link

Unfortunately, its not possible to set a relative path such as <base href="/sba/"> anymore. Behind a proxy without forward headers, this approach is not working.

@spyro2000
Copy link

spyro2000 commented Aug 12, 2021

I have the same problem with the mixed-content block in the browser and the base href set to a fixed http url. Unfortunately server.use-forward-headers: true didn't help.

EDIT:

Was able to resolve this by setting the following spring properties:

  forward-headers-strategy: framework # 'native' may work also
  use-forward-headers: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants