# OpenGnsys ogdhcp configuration for Apache.

<VirtualHost *:80>
    ServerName localhost
    ServerAlias api-test
    DocumentRoot /opt/ogdhcp/public

    <Directory /opt/ogdhcp/public>
    	AllowOverride None
    	Require all granted
    	Header set Access-Control-Allow-Origin "*"
    	Header set Access-Control-Allow-Methods "GET,POST,OPTIONS,DELETE,PUT"
    	Header set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
    	FallbackResource /index.php
	</Directory>

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^/opengnsys3/rest/dhcp/index\.php - [L]
        RewriteRule ^/opengnsys3/rest/dhcp/(.*)$ /opengnsys3/rest/dhcp/index.php [QSA,L]
    </IfModule>

    <FilesMatch \.php$>
        SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost/" 
    </FilesMatch>

    ErrorLog ${APACHE_LOG_DIR}/ogdhcp_error.log
    CustomLog ${APACHE_LOG_DIR}/ogdhcp_access.log combined
</VirtualHost>
