dah85.com

*not* just another blog ;)

It's a long-winded title, but it's fitting.

I was trying to work out how to set up VestaCP so that when someone visits the IP of the server, it can go to a specific website instead of the first website that was configured, which in my case, is not desired.

So basically what made me want to do this is there seem to be a lot of domains that are still pointing to my IP and I'd like to capture that traffic and forward them to my web design page just.

What we are going to do is change the order in which VestaCP and Apache will look at websites in this case.

First, we'll edit /etc/apache2/conf.d/vesta.conf

nano /etc/apache2/conf.d/vesta.conf 

Then move the website you want to the top of the list, then save (control+x)

Once you've done that, we need to restart nginx and apache

service apache2 restart
service nginx restart

Now when you go to the website by the IP or a domain that's not hosted by you, it'll forward to the first website in that list. Neat, eh?

Redirecting domains with VestaCP

- Posted in Quick Tip by with comments

I have been looking for a way to redirect domain1.com to domain2.com even if the address is domain1.com/blah/random it will always redirect to domain2.com

We need to make a .htaccess file in the public_html folder and add the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain1.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain1.com [NC]
RewriteRule ^(.*)$ http://domain2.com/ [L,R=301,NC]

If we want it to forward them like this, example1.com/blah to example2.com/blah, we'd use:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain1.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain1.com [NC]
RewriteRule ^(.*)$ http://domain2.com/$1 [L,R=301,NC]

In a previous post I spoke about setting up the SSL cert for mail, but the web interface also needs SSL set up. The steps are actually similar, but without the extra bit for mail.

Here's what I did to fix it, just make sure you replace the example with your own domain. If you aren't running as root, use these commands otherwise put sudo in front of them all:

ln -s /home/admin/conf/web/ssl.example.com.pem /usr/local/vesta/ssl/certificate.crt
ln -s /home/admin/conf/web/ssl.example.com.key /usr/local/vesta/ssl/certificate.key

If that didn't do the trick, restart apache and vestacp and it will now work with your new cert :)

Setting up SSL for Mail in VestaCP

- Posted in Quick Tip by with comments

I'm still playing with my VestaCP install, and I've found that the outgoing mail doesn't work correctly when using Thunderbird or any other mail client except webmail which works perfectly.

It turns out there's an issue with the SSL certificates and EXIM (the mail server)

Here's what I did to fix it, just make sure you replace the example with your own domain. If you aren't running as root, use these commands otherwise put sudo in front of them all:

ln -s /home/admin/conf/web/ssl.example.com.pem /usr/local/vesta/ssl/certificate.crt
ln -s /home/admin/conf/web/ssl.example.com.key /usr/local/vesta/ssl/certificate.key

setfacl -m user:Debian-exim:r-- /home/admin/conf/web/ssl.example.com.pem
setfacl -m user:Debian-exim:r-- /home/admin/conf/web/ssl.example.com.key

chgrp mail /home/admin/conf/web/ssl.example.com.pem
chmod 660 /home/admin/conf/web/ssl.example.com.pem
chgrp mail /home/admin/conf/web/ssl.example.com.key
chmod 660 /home/admin/conf/web/ssl.example.com.key

Now you should be able to send email from a mail client without it complaining about certificates :)

Finding the SQL password in VestaCP

- Posted in Quick Tip by with comments

I've been playing with VestaCP lately, getting it all set up the way I like and I had a need to manually edit the databases and found that there was a root password set that I never set.

The password is hidden away in a file, to get to it do this:

sudo nano /usr/local/vesta/conf/mysql.conf

You'll find the password in there :)