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

Custom HTTP redirects #856

Closed
krizhanovsky opened this issue Nov 6, 2017 · 2 comments
Closed

Custom HTTP redirects #856

krizhanovsky opened this issue Nov 6, 2017 · 2 comments

Comments

@krizhanovsky
Copy link
Contributor

krizhanovsky commented Nov 6, 2017

While HSTS (RFC 6797) can be implemented just by adding Strict-Transport-Security header, there also must be implemented redirect from HTTP port to the same URL by HTTPS (HTTP redirects are common practice for HSTS implementation).

Please add a functional test for HSTS checking that the right header is added to all the responses and HTTP request is correctly redirected to HTTPS.

The Wiki update is required - we have to add redirect statement.

@krizhanovsky krizhanovsky added this to the 0.5.0 Web Server milestone Nov 6, 2017
@krizhanovsky krizhanovsky modified the milestones: 1.0 Web Server, 0.6 KTLS Jan 8, 2018
@krizhanovsky krizhanovsky modified the milestones: 0.6 KTLS, 0.7 HTTP/2 Jul 15, 2018
@krizhanovsky
Copy link
Contributor Author

Adding the header is just enough, see Nginx's doc for example. So I added the header description to the Wiki pages

and close the task.

@krizhanovsky krizhanovsky changed the title HTTP Strict Transport Security HTTP redirects Aug 30, 2018
@krizhanovsky
Copy link
Contributor Author

krizhanovsky commented Aug 30, 2018

Actually, while we're send HTTP redirects on JS and cookie challenges, we're still unable to send custom redirects, e.g. if a user wants to redirect all HTTP traffic to some other HTTPS resource. Anyway HTTP redirects are very useful for HTTP proxies, so I redefine the issue and reopen it. See https://tools.ietf.org/html/rfc7231#section-6.4 and https://tools.ietf.org/html/rfc7538 for the standard for the redirections.

JS and cookie redirects shall use the same mechanism as for generic redirects.

HTTPtables redirect action

HTTPtables must be able to redirect an HTTP request by a new redirect action. Just like Nginx we should support relative and absolute redirects.

   http_chain NAME {
	[ FIELD [FIELD_NAME] == (!=) ARG ] -> CODE ["string" | url];
	...
}

, where CODE is an integer HTTP response code, e.g. 301. "string" is an enclosed in double quotes status string, e.g. "Access denied because token is expired or invalid". url is non-quoted string. See also the format for the Nginx return.

Example configuration:

http_chain {
    # Absolute path
    uri == "http://*" -> 301 = https://$host$request_uri;

    # Relative path
    uri == "*/services.html" -> 301 = /services;

    # Temporal redirection for the default index page only to a temporal landing page.
    uri == "/" -> 302 = /c++-services;
}

Variables

Note that we need to introduce the request_uri and host variables:

  • request_uri - matches everything after the protocol (i.e. after http:// or https://)
  • host - the value of Host header

See #907 for the design considerations.

Documentation and testing

Please update the wiki pages mentioned above and the page for HTTP tables. Please provide full example for HSTS (like there is a full configuration for Nginx in the doc).

Upon the release deploy the redirects on tempesta-tech.com site.

Testing issue is tempesta-tech/tempesta-test#214

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

No branches or pull requests

4 participants