adding server code
This commit is contained in:
35
src/server/apache-conf/000-default.conf
Normal file
35
src/server/apache-conf/000-default.conf
Normal file
@@ -0,0 +1,35 @@
|
||||
<VirtualHost *:80>
|
||||
ServerName cyberhex.srv
|
||||
DocumentRoot /var/www/html
|
||||
|
||||
#SSLEngine on
|
||||
#SSLCertificateFile /etc/apache2/certs/fullchain.pem
|
||||
#SSLCertificateKeyFile /etc/apache2/certs/privkey.pem
|
||||
#SSLCertificateChainFile /etc/apache2/certs/chain.pem
|
||||
|
||||
<Directory /var/www/html>
|
||||
Options FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
|
||||
<VirtualHost *:443>
|
||||
ServerName cyberhex.srv
|
||||
DocumentRoot /var/www/html
|
||||
|
||||
SSLEngine on
|
||||
SSLCertificateKeyFile /etc/apache2/certs/privkey.pem
|
||||
SSLCertificateFile /etc/apache2/certs/fullchain.pem
|
||||
# SSLCertificateChainFile /etc/apache2/certs/fullchain.pem
|
||||
|
||||
<Directory /var/www/html>
|
||||
Options FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
48
src/server/cyberhex-code/install.php
Normal file
48
src/server/cyberhex-code/install.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
$servername = "cyberhex-db";
|
||||
$username = "root";
|
||||
$password = "1234";
|
||||
$database = "cyberhex_db";
|
||||
|
||||
// Create connection
|
||||
$conn = new mysqli($servername, $username, $password);
|
||||
|
||||
// Check connection
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Create database
|
||||
$sql = "CREATE DATABASE IF NOT EXISTS $database";
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo "Database created successfully\n";
|
||||
} else {
|
||||
echo "Error creating database: " . $conn->error;
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
|
||||
// Connect to the new database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
// Check connection
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Create sample tables
|
||||
$sql = "CREATE TABLE IF NOT EXISTS users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
username VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo "Table 'users' created successfully\n";
|
||||
} else {
|
||||
echo "Error creating table: " . $conn->error;
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
45
src/server/docker-compose.yml
Normal file
45
src/server/docker-compose.yml
Normal file
@@ -0,0 +1,45 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
cyberhex-db:
|
||||
image: mysql:latest
|
||||
container_name: cyberhex-db
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: 1234
|
||||
networks:
|
||||
cyberhex-network:
|
||||
ipv4_address: 192.168.178.2
|
||||
# ports:
|
||||
# - "3306:3306"
|
||||
volumes:
|
||||
- cyberhex-db-storage:/var/lib/mysql
|
||||
|
||||
cyberhex-srv:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: srv_dockerfile
|
||||
container_name: cyberhex-srv
|
||||
networks:
|
||||
cyberhex-network:
|
||||
ipv4_address: 192.168.178.3
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
depends_on:
|
||||
- cyberhex-db
|
||||
volumes:
|
||||
- ./cyberhex-code:/var/www/html
|
||||
- ./apache-conf:/etc/apache2/sites-available
|
||||
- ./certs:/etc/apache2/certs
|
||||
|
||||
networks:
|
||||
cyberhex-network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 192.168.178.0/24
|
||||
|
||||
volumes:
|
||||
cyberhex-db-storage:
|
||||
external: true
|
||||
5
src/server/install.txt
Normal file
5
src/server/install.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
1: download the file docker-compose.yml and the folder cyberhex-code
|
||||
2: create the cyberhex-db-storage volume
|
||||
3: request some ssl certs via certbot form letsencrypt and put them into certs/
|
||||
sudo certbot certonly --manual --preferred-challenges=http --http-01-port=8080
|
||||
3: use docker-compose up to start the whole thing
|
||||
7
src/server/srv_dockerfile
Normal file
7
src/server/srv_dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
# Extend the official PHP image
|
||||
FROM php:apache
|
||||
|
||||
# Install the mysqli extension
|
||||
RUN docker-php-ext-install mysqli
|
||||
RUN a2enmod ssl
|
||||
RUN service apache2 restart
|
||||
Reference in New Issue
Block a user