# Apache Virtual Host Configuration for Moodle
# Place this in /etc/apache2/sites-available/moodle.conf

<VirtualHost *:80>
    ServerName your-domain.com
    ServerAlias www.your-domain.com
    DocumentRoot /var/www/html/moodle
    
    <Directory /var/www/html/moodle>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
        
        # PHP settings for Moodle
        php_value upload_max_filesize 100M
        php_value post_max_size 100M
        php_value memory_limit 512M
        php_value max_execution_time 300
        php_value max_input_vars 5000
    </Directory>
    
    # Logging
    ErrorLog ${APACHE_LOG_DIR}/moodle_error.log
    CustomLog ${APACHE_LOG_DIR}/moodle_access.log combined
    
    # Security headers
    Header always set X-Content-Type-Options nosniff
    Header always set X-Frame-Options DENY
    Header always set X-XSS-Protection "1; mode=block"
</VirtualHost>

# SSL Virtual Host (recommended for production)
<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName your-domain.com
    ServerAlias www.your-domain.com
    DocumentRoot /var/www/html/moodle
    
    <Directory /var/www/html/moodle>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
        
        # PHP settings for Moodle
        php_value upload_max_filesize 100M
        php_value post_max_size 100M
        php_value memory_limit 512M
        php_value max_execution_time 300
        php_value max_input_vars 5000
    </Directory>
    
    # SSL Configuration
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/your-domain.crt
    SSLCertificateKeyFile /etc/ssl/private/your-domain.key
    
    # Logging
    ErrorLog ${APACHE_LOG_DIR}/moodle_ssl_error.log
    CustomLog ${APACHE_LOG_DIR}/moodle_ssl_access.log combined
    
    # Security headers
    Header always set X-Content-Type-Options nosniff
    Header always set X-Frame-Options DENY
    Header always set X-XSS-Protection "1; mode=block"
    Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
</VirtualHost>
</IfModule>