sys_vhost.j2 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {% if ansible_prolog -%}
  2. {% from 'templates/ansible/prolog.j2' import prolog with context %}
  3. {{ prolog() }}
  4. {% endif -%}
  5. # Nginx vhost for PHP system checks
  6. server {
  7. {% if phpsyscheck_vhostip or phpsyscheck_vhostport %}
  8. listen {% if phpsyscheck_vhostip %}{{ phpsyscheck_vhostip }}{% endif %}{% if phpsyscheck_vhostip and phpsyscheck_vhostport %}:{% endif %}{% if phpsyscheck_vhostport %}{{ phpsyscheck_vhostport }}{% endif %};
  9. {% endif %}
  10. server_name {{ phpsyscheck_vhostname }};
  11. access_log /var/log/nginx/sys.access.log main;
  12. error_log /var/log/nginx/sys.error.log;
  13. {% if phpsyscheck_ssl %}
  14. include letsencrypt;
  15. {% endif %}
  16. {% if phpsyscheck_ssl and ssl_certs_auto_installed.stdout_lines is defined and phpsyscheck_vhostname in ssl_certs_auto_installed.stdout_lines %}
  17. location / {
  18. return 301 https://{{ phpsyscheck_vhostname }}$request_uri;
  19. }
  20. {% else %}
  21. root /etc/phpsyscheck;
  22. index index.php;
  23. try_files $uri $uri/ /index.php;
  24. {% if phpsyscheck_http_auth %}
  25. auth_basic "Restricted Access";
  26. auth_basic_user_file /etc/nginx/auth_admin;
  27. {% if phpsyscheck_http_whitelist_ip|length > 0 %}
  28. {% for ip in phpsyscheck_http_whitelist_ip %}
  29. allow {{ ip }};
  30. {% endfor %}
  31. deny all;
  32. satisfy any;
  33. {% endif %}
  34. {% endif %}
  35. location ~ \.php(/|$) {
  36. include fastcgi_pass_fpm;
  37. }
  38. {% endif %}
  39. }
  40. {% if phpsyscheck_ssl and ssl_certs_auto_installed.stdout_lines is defined and phpsyscheck_vhostname in ssl_certs_auto_installed.stdout_lines %}
  41. server {
  42. listen {% if phpsyscheck_vhostip %}{{ phpsyscheck_vhostip }}:{% endif %}{% if phpsyscheck_vhostport %}{{ phpsyscheck_vhostport }}{% else %}443{% endif %} ssl;
  43. server_name {{ phpsyscheck_vhostname }};
  44. include vhost_ssl_auto-{{ phpsyscheck_vhostname }};
  45. access_log /var/log/nginx/sys.access.log main;
  46. error_log /var/log/nginx/sys.error.log;
  47. root /etc/phpsyscheck;
  48. index index.php;
  49. try_files $uri $uri/ /index.php;
  50. {% if phpsyscheck_http_auth %}
  51. auth_basic "Restricted Access";
  52. auth_basic_user_file /etc/nginx/auth_admin;
  53. {% if phpsyscheck_http_whitelist_ip|length > 0 %}
  54. {% for ip in phpsyscheck_http_whitelist_ip %}
  55. allow {{ ip }};
  56. {% endfor %}
  57. deny all;
  58. satisfy any;
  59. {% endif %}
  60. {% endif %}
  61. location ~ \.php(/|$) {
  62. include fastcgi_pass_fpm;
  63. }
  64. }
  65. {% endif %}