pma_vhost.j2 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. {% if ansible_prolog -%}
  2. {% from 'templates/ansible/prolog.j2' import prolog with context %}
  3. {{ prolog() }}
  4. {% endif -%}
  5. # Nginx vhost for phpmyadmin
  6. server {
  7. {% if phpmyadmin_vhostip or phpmyadmin_vhostport %}
  8. listen {% if phpmyadmin_vhostip %}{{ phpmyadmin_vhostip }}{% endif %}{% if phpmyadmin_vhostip and phpmyadmin_vhostport %}:{% endif %}{% if phpmyadmin_vhostport %}{{ phpmyadmin_vhostport }}{% endif %};
  9. {% endif %}
  10. server_name {{ phpmyadmin_vhostname }};
  11. access_log /var/log/nginx/pma.access.log main;
  12. error_log /var/log/nginx/pma.error.log;
  13. {% if phpmyadmin_ssl %}
  14. include letsencrypt;
  15. {% endif %}
  16. {% if phpmyadmin_ssl and ssl_certs_auto_installed.stdout_lines is defined and phpmyadmin_vhostname in ssl_certs_auto_installed.stdout_lines %}
  17. location / {
  18. return 301 https://{{ phpmyadmin_vhostname }}$request_uri;
  19. }
  20. {% else %}
  21. root /usr/share/phpmyadmin;
  22. index index.php;
  23. try_files $uri $uri/ /index.php;
  24. {% if phpmyadmin_http_auth %}
  25. auth_basic "Restricted Access";
  26. auth_basic_user_file /etc/nginx/auth_admin;
  27. {% if phpmyadmin_http_whitelist_ip|length > 0 %}
  28. {% for ip in phpmyadmin_http_whitelist_ip %}
  29. allow {{ ip }};
  30. {% endfor %}
  31. deny all;
  32. satisfy any;
  33. {% endif %}
  34. {% endif %}
  35. client_max_body_size 128m;
  36. location ~ \.php(/|$) {
  37. include fastcgi_pass_fpm;
  38. fastcgi_read_timeout 300s;
  39. {% if nginx_fpm_openbasedir_enforced %}
  40. fastcgi_param PHP_ADMIN_VALUE "upload_tmp_dir=/tmp\nopen_basedir=$document_root:/etc/phpmyadmin:/var/lib/phpmyadmin:/tmp:/usr/share:/tmp:/dev/random:/dev/urandom\nmax_execution_time=300\nupload_max_filesize=128M\npost_max_size=128M\nmax_input_vars=10000";
  41. {% else %}
  42. fastcgi_param PHP_ADMIN_VALUE "max_execution_time=240\nupload_max_filesize=128M\npost_max_size=128M\nmax_input_vars=10000";
  43. {% endif %}
  44. }
  45. {% endif %}
  46. }
  47. {% if phpmyadmin_ssl and ssl_certs_auto_installed.stdout_lines is defined and phpmyadmin_vhostname in ssl_certs_auto_installed.stdout_lines %}
  48. server {
  49. listen {% if phpmyadmin_vhostip %}{{ phpmyadmin_vhostip }}:{% endif %}{% if phpmyadmin_vhostport %}{{ phpmyadmin_vhostport }}{% else %}443{% endif %} ssl;
  50. server_name {{ phpmyadmin_vhostname }};
  51. include vhost_ssl_auto-{{ phpmyadmin_vhostname }};
  52. access_log /var/log/nginx/pma.access.log main;
  53. error_log /var/log/nginx/pma.error.log;
  54. root /usr/share/phpmyadmin;
  55. index index.php;
  56. try_files $uri $uri/ /index.php;
  57. {% if phpmyadmin_http_auth %}
  58. auth_basic "Restricted Access";
  59. auth_basic_user_file /etc/nginx/auth_admin;
  60. {% if phpmyadmin_http_whitelist_ip|length > 0 %}
  61. {% for ip in phpmyadmin_http_whitelist_ip %}
  62. allow {{ ip }};
  63. {% endfor %}
  64. deny all;
  65. satisfy any;
  66. {% endif %}
  67. {% endif %}
  68. client_max_body_size 128m;
  69. location ~ \.php(/|$) {
  70. include fastcgi_pass_fpm;
  71. fastcgi_read_timeout 300s;
  72. {% if nginx_fpm_openbasedir_enforced %}
  73. fastcgi_param PHP_ADMIN_VALUE "upload_tmp_dir=/tmp\nopen_basedir=$document_root:/etc/phpmyadmin:/var/lib/phpmyadmin:/tmp:/usr/share:/tmp:/dev/random:/dev/urandom\nmax_execution_time=300\nupload_max_filesize=128M\npost_max_size=128M\nmax_input_vars=10000";
  74. {% else %}
  75. fastcgi_param PHP_ADMIN_VALUE "max_execution_time=240\nupload_max_filesize=128M\npost_max_size=128M\nmax_input_vars=10000";
  76. {% endif %}
  77. }
  78. }
  79. {% endif %}