Netflix / zuul

Zuul is a gateway service that provides dynamic routing, monitoring, resiliency, security, and more.
Apache License 2.0
13.54k stars 2.39k forks source link

In zuul 2.x sample demo, a request routing to nginx-backend http service always got 404 error #434

Open whbg opened 6 years ago

whbg commented 6 years ago

Condition: 1.disable eureka, and then 2.choose ConfigurationBasedServerList

We found this error was relation to 'Host' header forward to real service. Or i did incorrect configuration(see below bold line)?

whbg commented 6 years ago

Instance env settings

region=us-east-1 environment=test

Eureka instance registration for this app

Name of the application to be identified by other services

eureka.name=zuul

The port where the service will be running and serving requests

eureka.port=7001

Virtual host name by which the clients identifies this service

eureka.vipAddress=${eureka.name}:${eureka.port}

For eureka clients running in eureka server, it needs to connect to servers in other zones

eureka.preferSameZone=false

Don't register locally running instances.

eureka.registration.enabled=false

Disable eureka

eureka.validateInstanceId=false

Loading Filters

zuul.filters.root=zuul-sample/src/main/groovy/com/netflix/zuul/sample/filters zuul.filters.locations=${zuul.filters.root}/inbound,${zuul.filters.root}/outbound,${zuul.filters.root}/endpoint zuul.filters.packages=com.netflix.zuul.filters.common

Load balancing backends with Eureka

eureka.shouldUseDns=true eureka.eurekaServer.context=discovery/v2 eureka.eurekaServer.domainName=discovery${environment}.netflix.net eureka.eurekaServer.gzipContent=true

eureka.serviceUrl.default=http://${region}.${eureka.eurekaServer.domainName}:7001/${eureka.eurekaServer.context}

api.ribbon.NIWSServerListClassName=com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList

api.ribbon.DeploymentContextBasedVipAddresses=api-test.netflix.net:7001

Load balancing backends without Eureka

disable auto service discovery

eureka.shouldFetchRegistry=false

api.ribbon.listOfServers=http://xx.com:80 ##{nginx-backend hostname}

api.ribbon.UseIPAddrForServer=false api.ribbon.client.NIWSServerListClassName=com.netflix.loadbalancer.ConfigurationBasedServerList ##{diff} api.ribbon.DeploymentContextBasedVipAddresses=api-test.netflix.net:7001

artgon commented 6 years ago

Which host header are you getting on your backend?

whbg commented 6 years ago
2018-05-11 10 01 42

configuration is , api.ribbon.listOfServers=http://xx.com:80 backend Host header is Host:localhost:7001(it should be Host:xx.com:80)

artgon commented 6 years ago

That's not how proxies are supposed to behave. You have to maintain the host header from the original request otherwise your service has no idea where the request came from.

liangGTY commented 6 years ago

I think it's better if the proxy overrides the host header to get the host from ribbon.listOfServers? @artgon

wongcoekfai commented 4 years ago

And so? how to fix this problem?

SMakhrov commented 3 years ago

I have the same problem. @artgon please help to solve this.

artgon commented 3 years ago

If you want to change the outbound host header, you can add a filter that modifies the inbound request headers.

github-actions[bot] commented 4 days ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.