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

Replace localhost urls to be configurable #57

Open
sophiaso opened this issue May 4, 2018 · 2 comments
Open

Replace localhost urls to be configurable #57

sophiaso opened this issue May 4, 2018 · 2 comments

Comments

@sophiaso
Copy link
Collaborator

sophiaso commented May 4, 2018

In gateway home page, several services links are provided which are with url localhost, to be changed.

@yaweiw
Copy link
Owner

yaweiw commented May 4, 2018

it now only works with "docker compose up" demo.

@sophiaso
Copy link
Collaborator Author

sophiaso commented May 8, 2018

Possible solutions:

  1. Use system properties in the generated cloud gateway index page to dynamically generate urls.
  • add environment variable to the dockerfile and docker-compose
  • use Spring thymeleaf template to write index page
  • ref to the system properties in the front index page with ${@environment.getProperty('GATEWAY_URL')}
  • Add Spring thymeleaf to the dependency and thymeleaf configuration in the template
  • add environment variable to the start script and readme etc about how to configure and run the downloaded Spring Cloud project
  1. Rewrite the gateway home page links with javascript.
  • gateway index page Spring Cloud modules href with port and subpath only,
    e.g., <a href=":8888/abc">ABC</href>
  • when page is firstly loaded, rewrite the href by adding the protocol and hostname to the href, e.g.,
<html>
<head>
<script>
function setHref() {
document.getElementById('modify-me').href = window.location.protocol + "//" + window.location.hostname + ":8080/other/";
}
</script>
</head>

<body onload="setHref()">
<a href="/other/" id="modify-me">Look at another port</a>
</body>
</html>

to e.g.,:
<a href="https://my.deployed.host:8888/abc">ABC</href>

Pros and Cons:

  1. Solution 1 is a little complex, many configurations and instructions for the user

  2. Solution 2 is easy to implement, but it relies on each Spring Cloud Microservices are deployed to the same host with different ports(azure web app only exposes 443 and 80 port, which makes it impossible to deploy to multiple ports), or at least the deployed hostnames share predefined rules, e.g., share same prefix or suffix.

e.g., home page with ABC.com
       eureka page with ABC.eureka.com
       hystrix page with ABC.hystrix.com

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

No branches or pull requests

2 participants