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

Fix redirect to http://_/ #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix redirect to http://_/ #8

wants to merge 1 commit into from

Conversation

yottatsa
Copy link

If site is empty, or redirect is not specified, it should use $http_host

@cloudlab-autobuild
Copy link
Collaborator

Can one of the admins verify this patch?

@yottatsa
Copy link
Author

I've sent patch to Jiří Konečný @jkonecny

Copy link

@pjediny pjediny left a comment

Choose a reason for hiding this comment

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

This introduces other issues, we should probably use the nginx $host variable

@@ -6,6 +6,6 @@ server {
{%- if site.redirect is defined %}
rewrite ^(.*) {{ site.redirect.get('protocol', 'http') }}://{{ site.redirect.get('host', '$server_name') }}{{ site.redirect.get('path', '$1') }} permanent;
{%- else %}
rewrite ^(.*) https://$server_name$1 permanent;
rewrite ^(.*) https://$http_host$1 permanent;
Copy link

Choose a reason for hiding this comment

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

$http_host can be undefined (HTTP/1.0) or defined with port, for example - the redirect from http://<...>:8080 to https://<...>:8080 would not work.

The underscore is a catch all $server_name, maybe it should be avoided or we could use $host variable to at least somewhat mitigate the issue.

Copy link
Author

Choose a reason for hiding this comment

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

Yep, $host is better, but not $servername.

Copy link
Author

Choose a reason for hiding this comment

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

@pjediny I've amended commit

If site is empty, or redirect is not specified, it should use $http_host
@cznewt
Copy link
Member

cznewt commented Oct 11, 2016

I'd handle this situation only in case the site.host is set '_' in all other cases it behaves as expected.

@yottatsa
Copy link
Author

@cznewt ok. BTW, do you have any tests?

@pjediny
Copy link

pjediny commented Oct 11, 2016

@cznewt What about a situation when the $server_name is not set at all or "", e.g. ip based virtual hosts? I think $host is a good solution and it has fallback to server_name incorporated. The only worry I have in this case is the HTTP/1.0 + default virtual host without server_name defined, but that should be very uncommon.

@yottatsa
Copy link
Author

$host will fallback to $server_name in case of HTTP/1.0, but this scenario is VERY uncommon for horizon.

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

Successfully merging this pull request may close these issues.

4 participants