Project

General

Profile

Redirect problem

Added by unixro almost 15 years ago

Assuming this scenario:
port 90 - standard http
port 6443 - https

How can i redirect from port 90 to 6443 on https. I can redirect it easily when it's on port 80 but i have no idea how to write the regexp to redirect it when i have a custom port.

I have something like this now:

$SERVER["socket"] == custom_port {
    ssl.engine                = "enable" 
    ssl.pemfile                = certificate_file
    url.rewrite-once =  (
                "/pro/(.*)$" => "/pro/$1",
                "/pro" => "/pro" 
    )
}
else $HTTP["host"] =~ "(.*)" {
    url.rewrite-once =  (
                "/pro/(.*)$" => "/pro/$1",
                "/pro" => "/pro",
        "/(.*)" => "/https/$1" 
    )
    url.redirect = (
        "/https/(.*)" => "https://%0"+custom_port+"/$1" 
    )
}


Replies (1)

RE: Redirect problem - Added by lightman about 11 years ago

I realize this is an old thread but I couldn't find the answer to this but finally figured it out. This will redirect any traffic on port 8080 to port 4343 on https

$SERVER["socket"] == ":4343" {
    ssl.engine = "enable" 
    ssl.pemfile = "/pathToPemFile/server.pem" 
}
else $SERVER["socket"] == ":8080" {
   $HTTP["host"] =~ "([^:/]+)" {
     url.redirect = ( "^/(.*)" => "https://%1:4343/$1" )
   }
}
    (1-1/1)