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

Patch from PUP-6366 #4997

Closed
wants to merge 1 commit into from
Closed

Conversation

buzzdeee
Copy link
Contributor

trusted facts with apache/nginx and puppetmaster unicorn

running unicorn behind nginx or apache reverse proxy, the
$trusted facts are not available to puppet.

The supported the +ExportCertData from Apache, only works
with Passenger module, but not with thin rack behind reverse
proxy, and esp. not with nginx.

Therefore I added an additionalheader that gets passed to unicorn: X-SSL-Client-Cert.
However, that header is sent as single line from Apache to unicorn,
and not as valid PEM encoded certificate. Therefore the gsub!
manipulations to restore a valid PEM certificate again.

To make use of it with Apache add this to the vhost:
RequestHeader set X-SSL-Client-Cert %{SSL_CLIENT_CERT}e

With nginx, there is a bit more trouble. Nginx has $ssl_client_cert
variable aswell, but nginx passes that variable on as multi-line header. Doh!
Unicorn doesn't like that at all.

To make it work with nginx, you need lua in nginx, then you need
something like this in your vhost:

location / {
set_by_lua $client_cert "return ngx.var.ssl_client_raw_cert:gsub('\n',' ')";
proxy_set_header X-SSL-Client-Cert $client_cert;
}

@puppetcla
Copy link

CLA signed by all contributors.

trusted facts with apache/nginx and puppetmaster unicorn

running unicorn behind nginx or apache reverse proxy, the
$trusted facts are not available to puppet.

The supported the +ExportCertData from Apache, only works
with Passenger module, but not with thin rack behind reverse
proxy, and esp. not with nginx.

Therefore I added an additionalheader that gets passed to unicorn: X-SSL-Client-Cert.
However, that header is sent as single line from Apache to unicorn,
and not as valid PEM encoded certificate. Therefore the gsub!
manipulations to restore a valid PEM certificate again.

To make use of it with Apache add this to the vhost:
RequestHeader set X-SSL-Client-Cert %{SSL_CLIENT_CERT}e

With nginx, there is a bit more trouble. Nginx has $ssl_client_cert
variable aswell, but nginx passes that variable on as multi-line header. Doh!
Unicorn doesn't like that at all.

To make it work with nginx, you need lua in nginx, then you need
something like this in your vhost:

 location / {
   set_by_lua $client_cert "if ngx.var.ssl_client_raw_cert then return ngx.var.ssl_client_raw_cert:gsub('\\n',' ') end";
   proxy_set_header X-SSL-Client-Cert $client_cert;
 }
@HAIL9000
Copy link
Contributor

HAIL9000 commented Aug 3, 2016

Closing this one in favor of #5170 which has a reformatted commit message

@HAIL9000 HAIL9000 closed this Aug 3, 2016
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

Successfully merging this pull request may close these issues.

None yet

3 participants