How to add a proxy rule in the ood_portal.yml file?

Hi,

let me explain my subject :slight_smile:

i want to proxy an url like “https://my_ood_frontend.cluster.org/blabla/…” seen by the users into " https://my_ood_frontend.cluster.org:8443/…" by example.

how to add this rule in the ood_portal.yml file ?

thanks for your time

jean-marie

I don’t think you can by editing the confg yml. We just don’t allow for arbitrary redirect rules, though maybe we should?

Most folks modify the resulting /opt/rh/httpd24/root/etc/httpd/conf.d/ood-portal.conf when they need to do something like this. But this comes at a price, those edits will not be preserved next time you reconfigure using the ood-portal-generator. So you’d have to add them back every time.

So, if you really need to do this, I’d suggest hacking the template it’s created from.

This is the file to modify: /opt/ood/ood-portal-generator/templates/ood-portal.conf.erb. Please make a back up copy before you make any modifications. If you get into trouble, just start over from ood-portal.conf.erb.backup (or whatever you name the backup file).

It’s a ruby ERB template file, but you can just add hard coded rules. Here’s the section I pulled where we’re redirecting / to /pun/sys/dashboard. Just add your items after it like so,

  <%- if @root_uri -%>
  # Redirect root URI to specified URI
  #
  #     <%= @ssl ? "https" : "http" %>://<%= @servername || "localhost" %>:<%= @port %>/
  #     #=> <%= @ssl ? "https" : "http" %>://<%= @servername || "localhost" %>:<%= @port %><%= @root_uri %>
  #
  RedirectMatch ^/$ "<%= @root_uri %>"
  <%- end -%>

  # Here are my additional redirects modified in the template
  RedirectMatch ^/blah-blah-blah$ "/yadda-yadda-yadda"

I tell if you want a redirect or a rewrite. This explanation was for a redirect, but it would be the same for rewrite like this if I wanted to get rid of the /pun/sys bit of the url for my super cool app.

  # Here are my additional redirects & rewrites modified in the template
  RedirectMatch ^/blah-blah-blah$ "/yadda-yadda-yadda"
  RewriteRule ^/pun/sys/super-cool-app$ "/super-cool-app"

Thanks a lot, Jeff !

I have modified my ood-portal.conf.erb file with this expression :smile:

  • RewriteRule “^/blabla/(.*)” “https://<%= @servername %>:8443/$1”

and it runs fine :smile:

jean-marie

Just be careful next time you upgrade, at the very least we’ll replace the file outright in an upgrade, so keep a backup in a second location (or in source control). At the very most we’d add things to it so you would have to merge your changes into the new file as you update.

My 1st rule has been replaced in the ood-portal.conf.erb file by 2 rules :

  • ganglia translation
  • noVNC translation

the modification :

"# JMS mod the 17th 09/2019 : URL redirection

SSLProxyEngine on

" # proxy rule for ganglia
<Location “/ganglia”>
ProxyPass “<%=@gangliaserver%>/ganglia” connectiontimeout=5 timeout=30
ProxyPassReverse “<%=@gangliaserver%>/ganglia”

" # proxy rule for noVNC
<Location “/noVNC”>
ProxyPass “https://<%= @servername %>:8443/” connectiontimeout=5 timeout=30
ProxyPassReverse “https://<%= @servername %>:8443/”

RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule “/(.*)” “wss://<%= @servername %>:8443/$1” [P,L]

#end of JMS mod the 17th 09/2019