sys_vhost.j2 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. {% if ansible_prolog -%}
  2. {% from 'templates/ansible/prolog.j2' import prolog with context %}
  3. {{ prolog() }}
  4. {% endif -%}
  5. # Apache vhost for PHP system checks
  6. <VirtualHost {%if phpsyscheck_vhostip %}{{ phpsyscheck_vhostip }}{% else %}*{% endif %}:{%if phpsyscheck_vhostport %}{{ phpsyscheck_vhostport }}{% else %}80{% endif %}>
  7. ServerName {{ phpsyscheck_vhostname }}
  8. Include conf-available/letsencrypt.conf
  9. {% if phpsyscheck_ssl and ssl_certs_auto_installed.stdout_lines is defined and phpsyscheck_vhostname in ssl_certs_auto_installed.stdout_lines %}
  10. RedirectMatch 301 ^(?!/\.well-known/acme-challenge/).* https://{{ phpsyscheck_vhostname }}$0
  11. {% else %}
  12. DocumentRoot /etc/phpsyscheck
  13. DirectoryIndex index.php
  14. {% if phpsyscheck_http_auth %}
  15. <Location />
  16. AuthType basic
  17. AuthName "Restricted Access"
  18. AuthUserFile /etc/apache2/auth_admin
  19. <RequireAny>
  20. {% if phpsyscheck_http_whitelist_ip|length > 0 %}
  21. Require ip {{ phpsyscheck_http_whitelist_ip | join(' ') }}
  22. {% endif %}
  23. Require valid-user
  24. </RequireAny>
  25. </Location>
  26. {% endif %}
  27. <Directory /etc/phpsyscheck>
  28. Options None
  29. AllowOverride None
  30. Require all granted
  31. </Directory>
  32. {% if with_fpm|bool %}
  33. Include conf-available/fpm-pool.conf
  34. {% endif %}
  35. LogLevel warn
  36. CustomLog ${APACHE_LOG_DIR}/sys.access.log combined
  37. ErrorLog ${APACHE_LOG_DIR}/sys.error.log
  38. {% endif %}
  39. </VirtualHost>
  40. {% if phpsyscheck_ssl and ssl_certs_auto_installed.stdout_lines is defined and phpsyscheck_vhostname in ssl_certs_auto_installed.stdout_lines %}
  41. <VirtualHost {%if phpsyscheck_vhostip %}{{ phpsyscheck_vhostip }}{% else %}*{% endif %}:{%if phpsyscheck_vhostport %}{{ phpsyscheck_vhostport }}{% else %}443{% endif %}>
  42. ServerName {{ phpsyscheck_vhostname }}
  43. <IfModule http2_module>
  44. Protocols h2 http/1.1
  45. </IfModule>
  46. Include vhost_ssl_auto-{{ phpsyscheck_vhostname }}.conf
  47. DocumentRoot /etc/phpsyscheck
  48. DirectoryIndex index.php
  49. {% if phpsyscheck_http_auth %}
  50. <Location />
  51. AuthType basic
  52. AuthName "Restricted Access"
  53. AuthUserFile /etc/apache2/auth_admin
  54. <RequireAny>
  55. {% if phpsyscheck_http_whitelist_ip|length > 0 %}
  56. Require ip {{ phpsyscheck_http_whitelist_ip | join(' ') }}
  57. {% endif %}
  58. Require valid-user
  59. </RequireAny>
  60. </Location>
  61. {% endif %}
  62. <Directory /etc/phpsyscheck>
  63. Options None
  64. AllowOverride None
  65. Require all granted
  66. </Directory>
  67. <IfModule php7_module>
  68. php_admin_value max_execution_time 240
  69. php_admin_value upload_max_filesize 128M
  70. php_admin_value post_max_size 128M
  71. </IfModule>
  72. {% if with_fpm|bool %}
  73. Include conf-available/fpm-pool.conf
  74. {% endif %}
  75. LogLevel warn
  76. CustomLog ${APACHE_LOG_DIR}/sys.access.log combined
  77. ErrorLog ${APACHE_LOG_DIR}/sys.error.log
  78. </VirtualHost>
  79. {% endif %}