apache-unified.conf 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <VirtualHost *:80>
  2. ServerName inventory.local
  3. DocumentRoot /var/www/html/frontend/dist
  4. # Enable CORS headers for API requests
  5. Header always set Access-Control-Allow-Origin "*"
  6. Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
  7. Header always set Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With"
  8. Header always set Access-Control-Allow-Credentials "true"
  9. # Handle preflight requests
  10. RewriteEngine On
  11. RewriteCond %{REQUEST_METHOD} OPTIONS
  12. RewriteRule ^(.*)$ $1 [R=200,L]
  13. # API routes - redirect to PHP backend
  14. Alias /api /var/www/html/api
  15. # Static files and frontend routes
  16. <Directory "/var/www/html/frontend/dist">
  17. Options -Indexes +FollowSymLinks
  18. AllowOverride All
  19. Require all granted
  20. # Vue.js SPA routing - fallback to index.html
  21. RewriteEngine On
  22. RewriteBase /
  23. RewriteRule ^index\.html$ - [L]
  24. RewriteCond %{REQUEST_FILENAME} !-f
  25. RewriteCond %{REQUEST_FILENAME} !-d
  26. RewriteRule . /index.html [L]
  27. </Directory>
  28. # PHP backend directory
  29. <Directory "/var/www/html">
  30. Options -Indexes +FollowSymLinks
  31. AllowOverride All
  32. Require all granted
  33. # Handle PHP files
  34. <FilesMatch "\.php$">
  35. SetHandler application/x-httpd-php
  36. </FilesMatch>
  37. </Directory>
  38. # API directory
  39. <Directory "/var/www/html/api">
  40. Options -Indexes +FollowSymLinks
  41. AllowOverride All
  42. Require all granted
  43. # Handle PHP files
  44. <FilesMatch "\.php$">
  45. SetHandler application/x-httpd-php
  46. </FilesMatch>
  47. </Directory>
  48. # Security headers
  49. Header always set X-Content-Type-Options nosniff
  50. Header always set X-Frame-Options DENY
  51. Header always set X-XSS-Protection "1; mode=block"
  52. # Error handling
  53. ErrorLog ${APACHE_LOG_DIR}/error.log
  54. CustomLog ${APACHE_LOG_DIR}/access.log combined
  55. </VirtualHost>