# How to add a proxy rule in the ood\_portal.yml file?

**URL:** <https://discourse.openondemand.org/t/how-to-add-a-proxy-rule-in-the-ood-portal-yml-file/488>\
**Category:** Get Help\
**Created:** [September 13, 2019, 5:38am UTC](https://discourse.openondemand.org/t/how-to-add-a-proxy-rule-in-the-ood-portal-yml-file/488 "2019-09-13T05:38:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jms27000](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jms27000/32/147_2.png) [@jms27000](https://discourse.openondemand.org/u/jms27000)\
**Post date:** [September 13, 2019, 5:38am UTC](https://discourse.openondemand.org/t/how-to-add-a-proxy-rule-in-the-ood-portal-yml-file/488/1 "2019-09-13T05:38:06Z")

</div>

Hi,

let me explain my subject 🙂

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

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [September 16, 2019, 2:50pm UTC](https://discourse.openondemand.org/t/how-to-add-a-proxy-rule-in-the-ood-portal-yml-file/488/2 "2019-09-16T14:50:57Z")

</div>

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,

```ruby
  <%- 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](https://httpd.apache.org/docs/2.4/rewrite/remapping.html). 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.

```bash
  # 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"

```

---

<div class="post-metadata">

**Author:** ![jms27000](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jms27000/32/147_2.png) [@jms27000](https://discourse.openondemand.org/u/jms27000)\
**Post date:** [September 17, 2019, 3:49am UTC](https://discourse.openondemand.org/t/how-to-add-a-proxy-rule-in-the-ood-portal-yml-file/488/3 "2019-09-17T03:49:30Z")

</div>

Thanks a lot, Jeff !

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

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

and it runs fine 😄

jean-marie

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [September 17, 2019, 1:32pm UTC](https://discourse.openondemand.org/t/how-to-add-a-proxy-rule-in-the-ood-portal-yml-file/488/4 "2019-09-17T13:32:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jms27000](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jms27000/32/147_2.png) [@jms27000](https://discourse.openondemand.org/u/jms27000)\
**Post date:** [September 21, 2019, 11:21am UTC](https://discourse.openondemand.org/t/how-to-add-a-proxy-rule-in-the-ood-portal-yml-file/488/5 "2019-09-21T11:21:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [September 23, 2019, 1:25pm UTC](https://discourse.openondemand.org/t/how-to-add-a-proxy-rule-in-the-ood-portal-yml-file/488/6 "2019-09-23T13:25:47Z")

</div>

Those entries aren’t from [the source file](https://github.com/OSC/ondemand/blob/master/ood-portal-generator/templates/ood-portal.conf.erb), maybe a colleague of yours added them?

You may want to store the file in a source control like git.

---

<div class="post-metadata">

**Author:** ![jms27000](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jms27000/32/147_2.png) [@jms27000](https://discourse.openondemand.org/u/jms27000)\
**Post date:** [September 24, 2019, 3:11am UTC](https://discourse.openondemand.org/t/how-to-add-a-proxy-rule-in-the-ood-portal-yml-file/488/7 "2019-09-24T03:11:50Z")

</div>

Sorry for my poor english writing. i wanted to say : “i have replaced the 1st rule by a second version to have a real proxy mode implemented, and not a simple URL translation”.

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [September 25, 2019, 6:08pm UTC](https://discourse.openondemand.org/t/how-to-add-a-proxy-rule-in-the-ood-portal-yml-file/488/8 "2019-09-25T18:08:21Z")

</div>

Oh!!! I’m so sorry, it was my fault for jumping to the assumption it was an issue instead of just a statement for clarity.

Good luck with everything else!

---

<div class="post-metadata">

**Author:** ![westburg.2](https://avatars.discourse-cdn.com/v4/letter/w/0ea827/32.png) [@westburg.2](https://discourse.openondemand.org/u/westburg.2)\
**Post date:** [May 26, 2022, 3:22pm UTC](https://discourse.openondemand.org/t/how-to-add-a-proxy-rule-in-the-ood-portal-yml-file/488/9 "2022-05-26T15:22:20Z")

</div>


