Project

General

Profile

SSL only on vhost

Added by wg1337 over 16 years ago

Hi!
I just found out that SSL with Lighttpd can be very useful.
The certificate is bit buggy, IE7 says that there is an error with it, but will try to fix that later (self-signed, did the import but not sure if right).
The main reason I need SSL is phpmyadmin.
Since last time there have been many hack attempts and one time lasted saddly and now I'm trying to add the max security as possible.
So I have a vhost here - "/var/www/mysql.host.com/htdocs" and the phpmyadmin is in right there.
It is fine with SSL, but it is wrong with other pages with SSL.
I want to only from https://mysql.host.com to open the phpmyadmin, but it also opens from https://me.host.com.
Here is where I tried to fix that:
@$HTTP["host"] "me.host.com" {
...
}

$HTTP["host"] "mysql.host.com" {
$SERVER["socket"] == ":443" {
server.document-root = "/var/www/mysql.host.com/htdocs"
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd/ssl/mysql.host.com/server.pem"
}
}@

I don't know why, but sometimes it works and sometimes won't, but that could be just a lag.
After this I needed to add a redirect from HTTP to HTTPS.

$HTTP["host"] "mysql.host.com" {
$SERVER["socket"] ":443" {
server.document-root = "/var/www/mysql.host.com/htdocs"
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd/ssl/mysql.host.com/server.pem"
} else $SERVER["socket"] == ":80" {
url.redirect = ( "^/(.*)" => "https://%1/$1" )
}
}

Doesn't seem to redirect and doesn't seem to check if the host is mysql.host.com.
What is wrong?
Btw, any tips on adding extra security?