Op 21 augustus 2023
databaseserver $ sudo su - databaseserver # cd /etc/mysql/ssl databaseserver # scp ./client-cert.pem ./client-key.poem ./ca-cert.pem petervg@10.10.0.11:/home/petervg webserver $ sudo su - webserver # mkdir /var/local/datacenter webserver # cd ~petervg webserver # mv client-cert.pem client-key.pem ca-cert.pem /var/local/datacenter webserver # cd /var/local/datacenter webserver # chown www-data:root *
webserver $ sudo su - webserver # cd /remote/nfs/website webserver # vi secdatacenter.php <?php $connection = ""; try { $dbserver = "10.20.0.12"; $dbport = "3306"; $dbname = "datacenter"; $dbuser = "datacenter"; $dbpassword = "Deltion123!"; $connection = new PDO ( "mysql:host=$dbserver; dbname=$dbname", $dbuser, $dbpassword, [ PDO::MYSQL_ATTR_SSL_VERIFYSERVER_CERT => false, PDO::MYSQL_ATTR_SSL_KEY => '/var/local/datacenter/client-key.pem', PDO::MYSQL_ATTR_SSL_CERT => '/var/local/datacenter/client-cert.pem', PDO::MYSQL_ATTR_SSL_CA => '/var/local/datacenter/ca-cert.pem', ] ); } catch(PDOExeption $e) { print 'Connection failed: ' . $e->getMessage(); } $sql = 'SELECT servernaam,osnaam,ipbeheer,ipdatabase,ipnfs,ipiscsi,ipweb,ipnat FROM servers s JOIN oses o ON s.osid = o.osid;'; $statement = $connection->prepare($sql); $statement->execute(); $servers = $statement->fetchAll(); $table_rows=""; foreach ( $servers as $server ) { $table_rows .= '<tr> <td>'.$server['servernaam'].'</td> <td>'.$server['osnaam'].'</td> <td>'.$server['ipbeheer'].'</td> <td>'.$server['ipdatabase'].'</td> <td>'.$server['ipnfs'].'</td> <td>'.$server['ipiscsi'].'</td> <td>'.$server['ipweb'].'</td> <td>'.$server['ipnat'].'</td> </tr>'; } echo '<!DOCTYPE html> <html> <head> <title>Datacenter webapplicatie</title> <link rel="stylesheet" href="/css/opmaak.css"> <link rel="stylesheet" href="/css/datacenter.css"> </head> <body> <table> <thead> <tr> <td>Servernaam</td> <td>Osnaam</td> <td>Beheer</td> <td>Database</td> <td>NFS</td> <td>iSCSI</td> <td>Web</td> <td>NAT</td> </tr> </thead> <tbody> ' . $table_rows . ' </tbody> </table> </body> </html>'; ?>
webserver # php datacenter.php
webserver # vi css/datacenter.css thead tr td { background-color: red; color: white; margin: 0; padding: 5; }