chef / chef/chef-server

Data-collector proxy - Wrong Host header by Nginx?

Open
#1,862 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Aspect: Integration Component: automate integration Status: Help Wanted Status: To be prioritized Triage: Confirmed Type: Bug
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-header value is hardcoded;
  • at line range 80-85 the proxy-set-header directive 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.