lundi 15 octobre 2018

Proxmox, create external VNC access

Hello,

Sometimes using Proxmox, you can't connect to VM console, to troubleshot boot issues, slow network, java applet version, ...
To address thoses issues, the best solution is to create an external VNC session to login into your VM.
From your Proxmox server, open a VNC connection using NC (netcat) to forward port :

/bin/nc -l -p 5900 -w 100 -c '/usr/sbin/qm vncproxy VMID'

Install VNCTiger, very seasy and high-performance vnc client.

Connect to your Proxmox ip and port (ex: 5900), accept the certificats.
Login and password are the same to connect to your Proxmox, login : root@pam and your password.

Er voila, an emergency remote access to use when everything turns bad and your Windows VM does a BSOD.


vendredi 21 septembre 2018

Redirect HTTP to HTTPS using Apache and Google Cloud Platform Loadbalancer


Using Apache to redirect HTTP to HTTP, if https version of the site is not configured via Apache ModSSL it doesn't set %{HTTPS} variable to "on" and keeps redirecting infinitely.

The best way to do is to send X-Forwarded-Proto header from load balancer to Apache and configure RewriteCond as follow.

If not already done enablerewrite and ssl

a2enmod rewrite
a2enmod ssl
Then in HTTP vhost configure

<VirtualHost *:80>
....

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L,R=301]

...

</VirtualHost>

Instead of the common usage :


RewriteCond %{HTTPS} off

source : https://stackoverflow.com/a/19722706


 

lundi 18 juin 2018

Google cloud platform, forward HTTP to HTTPS


 Hello,

One of the common issue using GCP is loadbalancer HTTP to HTTPS forward.
Still a feature request but not resolved yet.

The best solution I found is the following.
Using Nginx server, HTTP connection are forward to HTTPS in server:443 part.

server {
        listen 443 ssl default_server;
        listen [::]:443 ssl;
if ($http_x_forwarded_proto = "http") {
        return 301 https://$host$request_uri;
    }
(rest of your configuration : ssl, ...)
}


This way your site is always HTTPS.

mardi 29 mai 2018

Configurer chrony Ubuntu chez AWS

Hello,

Souvent on oublie de configurer le temps et la zone et avec le temps (justement), il y a un dephasage, pour eviter ce probleme configurer NTP, remplace par Chrony.

Sur Ubuntu AWS :
  • sudo apt install chrony
  • sudoedit /etc/chrony/chrony.conf
  • Indiquer l'IP du serveur NTP AWS:
# Note that if Chrony tries to go "online" and dns lookup of the servers
# fails they will be discarded. Thus under some circumstances it is
# better to use IP numbers than host names.
server 169.254.169.123 prefer iburst
server 0.debian.pool.ntp.org offline minpoll 8
server 1.debian.pool.ntp.org offline minpoll 8
server 2.debian.pool.ntp.org offline minpoll 8
server 3.debian.pool.ntp.org offline minpoll 8
  • sudo /etc/init.d/chrony restart
on controle :

    • chronyc sources -v
    • chronyc tracking 
      • Leap status doit etre normal
    • date
      Ne pas oublie de refaire son image ensuite. 


      jeudi 22 mars 2018

      GCP SQL instance secure users

      Hello

      J'aime beaucoup Google Cloud Platform et leur solution de SQL instance.
      Facile de creer des bases de donnees, des utilisateurs, le cloud sql proxy, ...

      Mais attention quand vous creez des utilisateurs, ils auront les permissions root sur toute l'instance Mysql, quand vous avez plusieurs base de donnees dev, prod,  il vaut mieux securiser.

      Facile a faire, une fois creer la bd et l'utilisateur, il suffit de revoker les droits et de mettre les droits necessaire sur la nouvelle bd.

      Avec Sql-proxy on se connecte :
      mysql -h 127.0.0.1 -u monusr -p mabd
      Puis directement depuis Mysql on change les droits
      revoke all privileges,grant option from monusr;
      GRANT ALL ON mabd.* TO 'monusr';
      Et voila comment ca l'utilisateur peut administrer seulement sa base de donnees.
      On peut bien sur ajuster le grant en fonction des besoins.

      dimanche 11 février 2018

      Memo commandes GCP

      J'utilise beaucoup Google Cloud Platform.

      Je suis tres fan de leur CLI mais j'utilise plusieurs compte, projets et parfois je me souviens plus tres bien comment faire.

      Ci-dessous un petit memo des commandes :

      Pour ajouter un nouveau compte et selectionner le compte, projets, zones, ...
      $ gcloud init

      Pour lister ses configurations
      $ gcloud config configurations list

      Pour passer d'une configuration a l'autre
      $ gcloud config configurations activate NAME

      Pour lister les projets
      $ gcloud projects list

      Pour changer de projets
      $ gcloud config set project projectname

      Pour activer le compte lie a une configuration
      $ gcloud config set account monemail@gmail.com

      Pour tester les droits et l'environnement actif je liste les VM pour confirmer:
      $ gcloud compute instances list