Forum

Force HTTP to HTTPs

Rehen
19 December 2014, 17:05
Hello

I've a single IPv4 address with multiple SSL sites on it.
That works pretty fine (and the configuration was very easy in Hiawatha). However, I'm now trying to create virtualhosts for each of these sites on http (same IP) in order to redirect the user to HTTPs.

I've tried to create a virtualhost for each of the sites and then use urltoolkit to redirect the user. Unfortunately it didn't work.

Does anyone have an idea how to get a simple http2https redirection working?

Thanks in advance.

Hiawatha version: 9.9.
Operating System: Ubuntu 14
Hugo Leisink
20 December 2014, 11:31
Unlike in Apache, a virtual host in Hiawatha is reachable via every binding, SSL or no-SSL. If you want a virtual host to be only used via HTTPS and redirect HTTP visitors, simply use
VirtualHost {
...
RequireSSL = yes
}

Cet ca!
Rehen
20 December 2014, 12:45
Aaaah works now. There was a problem because I was using "RequiredBinding" in the VirtualHost section.
This works for me:

Binding {
Port = 80
Interface = X.X.X.X
}

Binding {
Port = 443
Interface = X.X.X.X
SSLcertFile = test_wild.pem
}

[...]

VirtualHost {
RequireSSL = yes
Hostname = a.test.com
ReverseProxy .* https://X.X.X.X/ 80
WebsiteRoot = /var/www/hiawatha
AccessLogfile = /var/log/hiawatha/atest/access-ssl.log
ErrorLogfile = /var/log/hiawatha/atest/error-ssl.log
}

VirtualHost {
RequireSSL = yes
Hostname = b.test.com
ReverseProxy .* https://X.X.X.X/ 30
WebsiteRoot = /var/www/hiawatha
AccessLogfile = /var/log/hiawatha/btest/access-ssl.log
ErrorLogfile = /var/log/hiawatha/btest/error-ssl.log
}


Thanks!
This topic has been closed.