Skip to content
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

pybind/mgr/dashboard: fix reverse proxy support #19758

Merged
merged 2 commits into from Jan 29, 2018
Merged

pybind/mgr/dashboard: fix reverse proxy support #19758

merged 2 commits into from Jan 29, 2018

Conversation

nrdmn
Copy link
Contributor

@nrdmn nrdmn commented Jan 3, 2018

Changes in 4f7007d break support for reverse http proxies by always redirecting to / on standby MGRs. This patch should fix it.

Fixes: http://tracker.ceph.com/issues/22557
Signed-off-by: Nick Erdmann n@nirf.de

@nrdmn nrdmn changed the title DNM: pybind/mgr/dashboard: fix reverse proxy support pybind/mgr/dashboard: fix reverse proxy support Jan 8, 2018
@@ -65,12 +65,24 @@ def recurse_refs(root, path):
def get_prefixed_url(url):
return global_instance().url_prefix + url

def prepare_url_prefix(url_prefix):
if url_prefix == None:
Copy link
Contributor

Choose a reason for hiding this comment

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

else:
if len(url_prefix) != 0:
if url_prefix[0] != '/':
url_prefix = '/'+url_prefix
Copy link
Contributor

Choose a reason for hiding this comment

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

could use

url_prefix = urlparse.urljoin('/', url_prefix)

if len(url_prefix) != 0:
if url_prefix[0] != '/':
url_prefix = '/'+url_prefix
if url_prefix[-1] == '/':
Copy link
Contributor

Choose a reason for hiding this comment

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

could just put:

url_prefix = url_prefix.rstrip('/')

@@ -65,12 +65,24 @@ def recurse_refs(root, path):
def get_prefixed_url(url):
return global_instance().url_prefix + url

def prepare_url_prefix(url_prefix):
if url_prefix == None:
url_prefix = ''
Copy link
Contributor

Choose a reason for hiding this comment

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

probably we can use #19948 to simplify this a little bit?

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'll change this as soon as #19948 is merged.

@nrdmn
Copy link
Contributor Author

nrdmn commented Jan 15, 2018

Thank you for your feedback! I added most of your suggestions, see my other comment.

@nrdmn
Copy link
Contributor Author

nrdmn commented Jan 22, 2018

@tchaikov I've modified my code to use your improvement from #19948.

This fixes http redirection for reverse http proxies

Fixes: http://tracker.ceph.com/issues/22557
Signed-off-by: Nick Erdmann <n@nirf.de>
Signed-off-by: Nick Erdmann <n@nirf.de>
@jcsp
Copy link
Contributor

jcsp commented Jan 29, 2018

2018-01-29 05:07:16,974.974 INFO:__main__:======================================================================
2018-01-29 05:07:16,974.974 INFO:__main__:FAIL: test_standby (tasks.mgr.test_dashboard.TestDashboard)
2018-01-29 05:07:16,974.974 INFO:__main__:----------------------------------------------------------------------
2018-01-29 05:07:16,974.974 INFO:__main__:Traceback (most recent call last):
2018-01-29 05:07:16,974.974 INFO:__main__:  File "/home/jspray/ceph.bravo/qa/tasks/mgr/test_dashboard.py", line 35, in test_standby
2018-01-29 05:07:16,975.975 INFO:__main__:    self.assertEqual(r.headers['Location'], failed_over_uri)
2018-01-29 05:07:16,975.975 INFO:__main__:AssertionError: 'http://senta04.front.sepia.ceph.com:7791/' != u'http://senta04.front.sepia.ceph.com:7791'

@tchaikov @nrdmn yeah, that looks like it was broken by this PR -- the call to set_uri on an active mgr should be setting something that matches what the standby redirects to (i.e. both should to have the trailing slash, or neither should)

@tchaikov
Copy link
Contributor

tchaikov commented Jan 29, 2018

@jcsp as @nrdmn mentioned last week, he's fixed the issue found in last rados qa batch. and it passed this batch. so i guess it's ready to merge. what do you think?

@jcsp jcsp merged commit c41ef5a into ceph:master Jan 29, 2018
@jcsp
Copy link
Contributor

jcsp commented Jan 29, 2018

👍 👍 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants