sys_vhost.j2 2.0 KB

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