cancel
Showing results for 
Search instead for 
Did you mean: 

redirect http to https

SOLVED
Contributor

Re: redirect http to https

> is there a way to do this dynamically so that anytime they add

> domainX.example.com, it gets redirected to https://domainX.example.com ?

 

RuleBuilder is designed to create very simple rules - but TrafficScript makes this VERY easy with this one-line rule:

 

 

http.changeSite( "https://" . http.getHostHeader() );

 

1. Look up the host header of the request

2. Add the prefix "https://"

3. Force redirect to the new URL, retaining the URL path of the original request

4. You could add other conditions, such as for certain content types, countries or force alternate redirects as needed

 

5. See the TrafficScript user guide at http://brocade.com/vadc-docs for details of http.changeSite() vs http.redirect()

 

This article shows a couple of other examples, including how to redirect to a country-specific website:

http://community.brocade.com/t5/vADC-Docs/HowTo-Redirect-HTTP-clients/ta-p/73709

 

Hope that helps!

 

 

Contributor

Re: redirect http to https

Re: multiple if/then sequence:

I guess that your sequence of if/then statements would work, but note that if a request is intended for "domain5" then you will execute each test several times over. Using a switch() or an array lookup might make it easier to maintain, but I don't think you can create that with RuleBuilder.

 

Re: Dynamic rules:

You may also be able to use the REST API to set rules dynamically - but the earlier TrafficScript example makes the redirect even easier.

 

Occasional Contributor

Re: redirect http to https

I'm planning to put this in:

 

$request = http.getRequest();
if( string.contains( http.getheader( "Host" ), "example.com" ) ){
http.changeSite( "https://" . http.getHostHeader() );
}

Occasional Contributor

Re: redirect http to https

I guess my question would be: what is the full syntax for the example(http.changeSite( "https://" . http.getHostHeader() ); you've given above?

Contributor

Re: redirect http to https

The detailed syntax for all TrafficScript functions can be found in the user guide. The most recent set of user guides can be found at http://brocade.com/vadc-docs

The current (17.1) TrafficScript guide is here:
http://www.brocade.com/en/backend-content/pdf-page.html?/content/dam/secure-external/product-guides/...
Contributor

Re: redirect http to https

HOWEVER: note that you need to have TrafficScript enabled to create custom rules like this. I recall that you said earlier that your licence does not include TrafficScript?
Occasional Contributor

Re: redirect http to https

This is a different client and they do have TrafficScript licensed.

New Member

Re: redirect http to https

using the ' http.changeSite' command send back to source a 301 HTTP redirect wit the new URL.

but i want to receive a HTTP request , change it to a HTTPS request i.e http://site1.com -> https://site2.com, 

and then send it on to a pool/back end node, is this possible

i have tried to use

 

# Rewrite host header if necessary
http.setHeader( "Host", "https://site2.com" );

pool.use( "pool_site2" );

 

But this fails

I keep on getting error 500, internal server error

 

is there another way to do this