Last time I’ve been working on my WordPress installation security. I added a few layers of high-level-security-paranoia. One of those was moving admin-panel to another TCP port (this was because I got only 1 public IP addr on this VPS and that means only one SSL legit certificate on 443 port. So – each SSL webservice on my server is now binded to a different TCP port and those are ‘SSL green’ ;) ).
Running admin panel over SSL is a thing which has already been described on a many websites:
But I haven’t found any article about running Admin Panel over SSL on different port than the website. So I took a deep dive (oh not that deep) into WordPress code and found, that it’s really that simple ;) Assuming my admin panel is running on TCP/445 port and website is as usual on TCP/80 all i had to do was this chunk of PHP code (maybe not that clean, but it’s just working fine) – put it in wp-config.php file:
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' && isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT']==445)