Add PUN-based mTLS proxy#5285
Open
mattmix wants to merge 1 commit intoOSC:masterfrom
Open
Conversation
Contributor
|
Hi thanks for the pull request. I can't quite look at it at the moment, because we're busy prepping the 4.2 release with WCAG fixes. So I'm not sure when we'll get to this, but won't likely get into 4.2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an attempt to address #1306. I wasn’t sure this was going to work, so I wrote a PoC first, which I’m submitting for feedback here.
It adds a PUN-based mTLS proxy configuration with the PUN managing the PKI infrastructure. The intended flow to the upstream server on the compute node looks like:
I had several things I wanted to do with this feature, addressing the requirements from #1306 and a few of my own:
secure. No-one should be able to proxy to another user's interactive job.(taken from issue)easy to install & maintain(taken from issue)caddyandslirp4netns. These packages are widely available on Ubuntu and RHEL derivatives (EPEL). Neither are services that need to run at the system level.I chose Caddy because I felt it was the easiest to install and configure reverse proxy option that supports mTLS authentication. This could be replaced with something else.
You can see the bash functions that automate the mTLS/Caddy/netns setup in this simplified interactive app: https://github.com/mattmix/bc_mtls_headers/blob/main/template/script.sh.erb. If the direction of this PR is acceptable, I would make a PR for ood_core to add them to the bash_helpers generation.
The simplest usage in script.sh of an interactive app looks like:
outer portis the port reported back toconnection.ymland which slirp4netns will forward through to Caddy inside the network namespace.inner portis what port the application server is listening on. This can be any port since it is in its own network namespace and cannot conflict with anything listening in the main netns. This function will generate a 35 day cert signed by the user's CA, create the netns, and start Caddy and the backend server.If Caddy injected headers are desired, those can be added in script.sh as:
The jankiest part of this solution is handling NGINX's need for a defined resolver for this kind of proxying (also noted in the issue). To try to make this easy to deal with, I have the PUN read out of
/etc/resolv.confand grab the first nameserver listed there unless configured otherwise. I don't really like that, but I think it will work almost all of the time.Things that I know are missing from this PR:
I just want to confirm that this is acceptable in principle before putting more time in.