Skip to content

Commit

Permalink
Merge pull request #74 from wdpypere/proxy_server
Browse files Browse the repository at this point in the history
allow a proxy_server
  • Loading branch information
ericfranz authored Oct 9, 2019
2 parents f798cd9 + 2f208c3 commit 7f94af5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions ood-portal-generator/lib/ood_portal_generator/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def initialize(opts = {})
@ssl = opts.fetch(:ssl, nil)
@listen_addr_port = opts.fetch(:listen_addr_port, nil)
@servername = opts.fetch(:servername, nil)
@proxy_server = opts.fetch(:proxy_server, @servername)
@port = opts.fetch(:port, @ssl ? "443" : "80")
@logroot = opts.fetch(:logroot, "logs")
@use_rewrites = opts.fetch(:use_rewrites, true)
Expand Down
6 changes: 6 additions & 0 deletions ood-portal-generator/share/ood_portal_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
# Default: null (don't use name-based Virtual Host)
#servername: null

# The server name used for rewrites
# Example:
# proxy_host: 'proxy.example.com'
# Default: The value of servername
#proxy_host: null

# The port specification for the Virtual Host
# Example:
# port: 8080
Expand Down
8 changes: 4 additions & 4 deletions ood-portal-generator/templates/ood-portal.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ Listen <%= addr_port %>
<% if @ssl && @use_rewrites -%>
# Redirect all http traffic to the https Open OnDemand portal URI
# http://*:<%= @port %>
# #=> <%= @ssl ? "https" : "http" %>://<%= @servername || "localhost" %>:<%= @port %>
# #=> <%= @ssl ? "https" : "http" %>://<%= @proxy_server || "localhost" %>:<%= @port %>
#
<VirtualHost *:80>
RewriteEngine On
RewriteRule ^(.*) <%= @ssl ? "https" : "http" %>://<%= @servername || "%{SERVER_NAME}" %>:<%= @port %>$1 [R=301,NE,L]
RewriteRule ^(.*) <%= @ssl ? "https" : "http" %>://<%= @proxy_server || "%{SERVER_NAME}" %>:<%= @port %>$1 [R=301,NE,L]
</VirtualHost>
<% end -%>

Expand All @@ -68,8 +68,8 @@ Listen <%= addr_port %>

<%- if @use_rewrites -%>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(<%= @servername %>(:<%= @port %>)?)?$ [NC]
RewriteRule ^(.*) <%= @ssl ? "https" : "http" %>://<%= @servername %>:<%= @port %>$1 [R=301,NE,L]
RewriteCond %{HTTP_HOST} !^(<%= @proxy_server %>(:<%= @port %>)?)?$ [NC]
RewriteRule ^(.*) <%= @ssl ? "https" : "http" %>://<%= @proxy_server %>:<%= @port %>$1 [R=301,NE,L]
<%- end -%>
<%- end -%>
Expand Down

0 comments on commit 7f94af5

Please sign in to comment.