These are chat archives for spring-cloud/spring-cloud

31st
Dec 2015
hacbq
@hacbq
Dec 31 2015 08:33

I use Spring Cloud Netflix service,
When I request url like http://mydomain.com/products
It's go from zuul --> my microservice
But when I call

request.getRequestURL()

It's like

http://HaLv:8757/products

HaLv it's my computer name
How can I get 'mydomain.com'

Dave Syer
@dsyer
Dec 31 2015 08:35
Is there a load balancer?
Who is serving traffic at mydomain.com?
hacbq
@hacbq
Dec 31 2015 08:40
Yes, it's load balancer. My partner call http://mydomain.com/products by Rest API
http://mydomain.com/products --> Nginx --> Zuul --> Product service

Here is my nginx config
upstream product_service{
server localhost:9004;
}

server {
listen 80;
server_name my_domain;

    location / {
        proxy_pass       http://product_service;
        proxy_set_header Host      $host;
    }
}

I get Host header and still get HaLv
I think because of Nginx :)

Dave Syer
@dsyer
Dec 31 2015 09:01
You need at least to set the forwarded-* headers in the proxy
And then you need to configure the back end apps to use those headers
Look at the Spring Boot user guide for a section on proxies and load balancers
hacbq
@hacbq
Dec 31 2015 10:44
Thank you so much :)