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

Always use https #5

Merged
merged 1 commit into from Apr 23, 2020
Merged

Conversation

michaelsembwever
Copy link
Member

No description provided.

@michaelsembwever
Copy link
Member Author

fyi @ossarga

Copy link
Contributor

@ossarga ossarga left a comment

Choose a reason for hiding this comment

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

I have read the relevant sections of the htaccess and mod_rewrite to understand what is going on here.

I have tested the regex in bash inside a Ubuntu docker container

root@ff2f9e8ca396:~# echo "/test/path" | sed -r 's/^\/?(.*)/https:\/\/www.example.com\/\1/'
https://www.example.com/test/path

I am confident that the RewriteRule and RewriteRule Flags are correct. I think this is ok to merge. There are two questions I have, both of which are non-blocking for this PR to be merged.

@@ -1 +1,4 @@
RewriteEngine On

RewriteCond %{HTTPS} !=on
Copy link
Contributor

Choose a reason for hiding this comment

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

In the Apache [mod_rewrite spec|https://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteCond] it says

The string comparison operator is part of the CondPattern argument and must be included in the quotes if those are used. Eg.

RewriteCond %{HTTP_USER_AGENT} "=This Robot/1.0"

Should the !=on be enclosed in quotes i.e. "!=on"?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so. Numerous places, including apache's own wiki, gives examples without the quotes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool. Sounds fine to me then.

@@ -1 +1,4 @@
RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
Copy link
Contributor

@ossarga ossarga Apr 23, 2020

Choose a reason for hiding this comment

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

The SERVER_NAME Server-Variable maps to the ServerName Directive. The syntax for this directive says that it can optionally include the scheme. This may cause problems with the rewrite rule if a scheme is included in the server name. Is it worth using the HTTP_HOST instead? The downside I see to this is that HTTP_HOST is the host name only where as the SERVER_NAME can include the port number.

Copy link
Member Author

Choose a reason for hiding this comment

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

have tested it. SERVER_NAME works fine in different scenarios.

@michaelsembwever
Copy link
Member Author

Tested on http://cassandra.staged.apache.org

@michaelsembwever michaelsembwever merged commit af57570 into apache:master Apr 23, 2020
michaelsembwever pushed a commit that referenced this pull request Mar 15, 2021
 patch by Chris Thornett, Erick Ramirez; reviewed by Erick Ramirez, Anthony Grasso for CASSANDRA-16496
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants