Data-collector proxy - Wrong Host header by Nginx?
Nobody has claimed this yet.
- Dominant language
- Erlang
- Stars
- 303
- Forks
- 211
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 5
Description
Hello,
I have setup the integration with Automate configuring the Chef Server to act as proxy for the data-collector.
However, the nodes are getting 401s when reporting to Automate.
In /etc/opscode/chef-server.rb, we specified:
data_collector['root_url'] = 'https://automate.internal-domain/data-collector/v0/'
data_collector['token'] = 'xxx'
data_collector['proxy'] = true
profiles['root_url'] = 'https://automate.internal-domain'
After investigation, it looks like Nginx is not passing the right Host header when proxying to data-collector.
Since our Automate sits behind a reverse proxy, he is not getting the traffic due to the wrong Host header.
This manual change in /var/opt/opscode/nginx/etc/chef_https_lb.conf resolves the issue for us:
location "/data-collector/" {
# proxy_set_header Host $host; # <-- comment this generated line
proxy_set_header Host automate.internal-domain; # <-- add this line
...
location ~ "^/organizations/([^/]+)/data-collector$" {
proxy_set_header Host automate.internal-domain; # <-- add this line
...
I might be wrong, but it looks like the configuration is generated from this template: https://github.com/chef/chef-server/blob/13.0.17/omnibus/files/private-chef-cookbooks/private-chef/templates/default/nginx/nginx_chef_api_lb.conf.erb#L69 where:
- at line 69 the
proxy-set-headervalue is hardcoded; - at line range 80-85 the
proxy-set-headerdirective is missing.
Is there a way to workaround this? At the moment, the fix gets overwritten after chef-server-ctl reconfigure.
Thank you
Luca
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the generated /var/opt/opscode/nginx/etc/chef_https_lb.conf and the referenced nginx_chef_api_lb.conf.erb template, especially line 69 and lines 80-85. Compare the data-collector locations with the reported manual workaround, then run chef-server-ctl reconfigure and verify that the generated proxy configuration preserves the required Host header.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nginx
- Domain
- infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100