Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Introduce new attributes to enable the use behind a proxy #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@
$prd_web_ui_logger_syslog_errors = true,
$prd_web_ui_port = '3080',
$prd_web_ui_timeout = '300',
$prd_web_ui_base_url = undef,

## JSON API Params
$prd_json_api_access_log = 'jsonapi_access.log',
$prd_json_api_base_url = 'http://localhost',
$prd_json_api_url = undef,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think $prd_json_api_base_url and $prd_json_api_url should always be the same if specified? So the new variable is unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my point of view, the $prd_json_api_base_url is the internal url (behind a proxy). The $prd_json_api_url is the public url in front of the proxy.
Internal we run the flapjack-api on http://localhost:3081/ and external on https://hostname/flapjack/api/ (where apache is the proxy wo cares about the authentication)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that they're both used in the source code for values that will be used externally -- in pages or Location HTTP headers as appropriate. (Unless the proxy is doing some sort of translation I guess? I'd have to review things in that case.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think abount a config like this:

Flapjack:

   web:
      port: 3080
      base_url: 'http://localhost:3080/'

Apache:

ProxyPass /flapjack/ http://localhost:3080/
ProxyPassReverse /flapjack/ http://localhost:3080/

This results in http://localhost:3080/ URLs in the content of https://hostname/flapjack/ on our setup using Apache 2.2. on Debian Linux.

The only "workaround" I found was changing the base_url. Which should be independent of the port.

$prd_json_api_logger_level = 'INFO',
$prd_json_api_logger_syslog_errors = true,
$prd_json_api_port = '3081',
Expand Down
11 changes: 11 additions & 0 deletions templates/etc/flapjack/flapjack_config.erb
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,14 @@ production:
port: <%=@prd_web_ui_port%>
timeout: <%=@prd_web_ui_timeout%>
access_log: '<%=@prd_log_dir-%><%=@prd_web_ui_accesslog-%>'
<% if @prd_web_ui_base_url -%>
base_url: '<%=@prd_web_ui_base_url-%>'
<% end -%>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be better expressed as:

<% if @prd_web_ui_base_url %>
<%   if @prd_web_ui_port %>
  base_url: '<%= @prd_web_ui_base_url -%>:<%= @prd_web_ui_base_port -%>'
<%   else %>
  base_url: '<%=@prd_web_ui_base_url -%>'
<%   end %>
<% end %>

with similar behaviour for the other URL-handling sections. (Not sure what indenting is appropriate there, adjust as required.)

It's actually probably better that these be handled in Flapjack code itself, but that'll be as part of a major version change/interface breakage I'd think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to define a custom internal port for flapjack but not use this in public (similar to my comment above). I think this is not possible with your proposal or do I missunderstand the possibilities?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's treat this as the same problem as above (with a different manifestation :)

<% if @prd_json_api_url -%>
api_url: '<%=@prd_json_api_url-%>'
<% else -%>
api_url: '<%=@prd_json_api_base_url-%>:<%=@prd_json_api_port-%>/'
<% end -%>
# Full path to location of logo file, e.g. /etc/flapjack/custom_logo.png
#logo_image_path: "/etc/flapjack/web/custom_logo/flapjack-2013-notext-transparent-300-300.png"
logger:
Expand All @@ -295,7 +302,11 @@ production:
port: <%=@prd_json_api_port%>
timeout: <%=@prd_json_api_timeout%>
access_log: '<%=@prd_log_dir-%><%=@prd_json_api_access_log%>'
<% if @prd_json_api_url -%>
base_url: '<%=@prd_json_api_url-%>'
<% else -%>
base_url: '<%=@prd_json_api_base_url-%>:<%=@prd_json_api_port-%>/'
<% end -%>
logger:
level: <%=@prd_json_api_logger_level%>
syslog_errors: <%=prd_jsonapi_syslog%>
Expand Down