sys_vhost.j2 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. auth_basic "Restricted Access";
  25. auth_basic_user_file /etc/nginx/auth_admin;
  26. location ~ \.php(/|$) {
  27. include fastcgi_pass_fpm;
  28. }
  29. {% endif %}
  30. }
  31. {% if phpsyscheck_ssl and ssl_certs_auto_installed.stdout_lines is defined and phpsyscheck_vhostname in ssl_certs_auto_installed.stdout_lines %}
  32. server {
  33. listen {% if phpsyscheck_vhostip %}{{ phpsyscheck_vhostip }}:{% endif %}{% if phpsyscheck_vhostport %}{{ phpsyscheck_vhostport }}{% else %}443{% endif %} ssl;
  34. server_name {{ phpsyscheck_vhostname }};
  35. include vhost_ssl_auto-{{ phpsyscheck_vhostname }};
  36. access_log /var/log/nginx/sys.access.log main;
  37. error_log /var/log/nginx/sys.error.log;
  38. root /etc/phpsyscheck;
  39. index index.php;
  40. try_files $uri $uri/ /index.php;
  41. auth_basic "Restricted Access";
  42. auth_basic_user_file /etc/nginx/auth_admin;
  43. location ~ \.php(/|$) {
  44. include fastcgi_pass_fpm;
  45. }
  46. }
  47. {% endif %}