-
Notifications
You must be signed in to change notification settings - Fork 271
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
Fixes #37761 - Allow rewrites needed for cockpit integration #1178
Conversation
f40d5a7
to
d641409
Compare
390a202
to
8dee101
Compare
8dee101
to
242bf3c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -71,7 +71,7 @@ class {'foreman': | |||
.without_content | |||
.with_ssl_content(%r{^<Location /webcon>$}) | |||
.with_ssl_content(%r{^ RewriteRule /webcon/\(\.\*\) ws://127\.0\.0\.1:19090/webcon/\$1 \[P\]$}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still needed? And for websockets we don't suffer from the same problem? I ask because I get the impression this line is redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is (without having explicitly tested that) that w/o this we do not get a protocol upgrade on EL8 (and Ubuntu Focal).
On EL9 (and Debian), we could use ProxyPass … upgrade=websocket
, but not on EL8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am afraid this is not making the webconsole work for me on CS9 :(
httpd-2.4.57-8.el9.x86_64
This is the version without the fix for CVE-2024-38474 and thus "obviosly" works.
old config
<Location /webcon>
ProxyPreserveHost On
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /webcon/(.*) ws://127.0.0.1:19090/webcon/$1 [P]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /webcon/(.*) http://127.0.0.1:19090/webcon/$1 [P]
</Location>
WORKS
new config
<Location /webcon>
ProxyPreserveHost On
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /webcon/(.*) ws://127.0.0.1:19090/webcon/$1 [P]
ProxyPass http://127.0.0.1:19090/webcon
</Location>
WORKS
config without explicit ws://
proxy
<Location /webcon>
ProxyPreserveHost On
ProxyPass http://127.0.0.1:19090/webcon
</Location>
FAILS with
Connection failed
There was an unexpected error while connecting to the machine.
config without explicit ws://
proxy but with upgrade=websocket
<Location /webcon>
ProxyPreserveHost On
ProxyPass http://127.0.0.1:19090/webcon upgrade=websocket
</Location>
I assumed (based on https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#wsupgrade) this would work, but alas, it does not, same "unexpected error". 🤔
httpd-2.4.62-1.el9.x86_64
That's the version with the CVE fix
old config
<Location /webcon>
ProxyPreserveHost On
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /webcon/(.*) ws://127.0.0.1:19090/webcon/$1 [P]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /webcon/(.*) http://127.0.0.1:19090/webcon/$1 [P]
</Location>
FAILS with "Forbidden" - this was expected
new config
<Location /webcon>
ProxyPreserveHost On
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /webcon/(.*) ws://127.0.0.1:19090/webcon/$1 [P]
ProxyPass http://127.0.0.1:19090/webcon
</Location>
FAILS with
Connection failed
There was an unexpected error while connecting to the machine.
config from #1177
<Location /webcon>
ProxyPreserveHost On
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /webcon/(.*) ws://127.0.0.1:19090/webcon/$1 [P,UnsafeAllow3F]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /webcon/(.*) http://127.0.0.1:19090/webcon/$1 [P,UnsafeAllow3F]
</Location>
FAILS with
Connection failed
There was an unexpected error while connecting to the machine.
In all "unexpected error" cases, I see my Firefox (in the network tab) trying to access wss://centos9-stream-katello-nightly.tanso.example.com/webcon/cockpit+=centos9-stream.tanso.example.com/socket
and quitting with "404 / WEBSOCKET CONNECTION REFUSED"
httpd agrees:
192.168.122.1 - - [17/Sep/2024:08:00:36 +0000] "GET /webcon/cockpit+=centos9-stream.tanso.example.com/socket HTTP/1.1" 404 1564 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0"
It's like the Upgrade: websocket
header (which is sent!) is completely ignored.
On EL8, with
in the config.
|
We probably should still merge this, to at least fix the issue on EL8… But it's still ugly. |
and EL <=9.4 |
But it's not broken with the old code on EL9.4 either, right? |
We're loading
Would those help? |
I tested these all after my initial "doesn't work" reply, and the changes do not have any visible effect. |
the plot thickens!It seems the WS request ends up routed to Rails, not foreman-cockpit, as I see the following in production.log:
And that explains the 404! And indeed, when I remove the following from the apache config:
it works. WTF |
Could it be the order of items? That Apache evaluates the rules from top to bottom. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The EL9 problem seems unrelated to the change at hand, so let's run with it.
When I use
Things work. But that'll break EL8 and Focal 😢 |
I want to drop both of those for 3.13. Any thoughts on OS version specific content if we want to backport this? |
You mean using proxypass with upgrade on OSes that support it, and without (and instead rewrite) on those which don't? |
Exactly |
Okay, let's try this! |
#1185 was merged instead |
A successor to #1177 which github won't allow me to reopen.