You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.6 KiB

  1. ---
  2. - name: Manage nginx webserver
  3. collections: [ 'debops.debops', 'debops.roles01',
  4. 'debops.roles02', 'debops.roles03' ]
  5. hosts: [ 'debian10' ]
  6. become: True
  7. environment: '{{ inventory__environment | d({})
  8. | combine(inventory__group_environment | d({}))
  9. | combine(inventory__host_environment | d({})) }}'
  10. vars_files:
  11. - ./../../vars/nginx.yml
  12. - ./../../vars/php.yml
  13. vars:
  14. nginx_acme: False
  15. nginx_http_extra_options: |
  16. client_max_body_size 100M;
  17. nginx_real_ip_from: ['172.16.30.0/24']
  18. nginx_default_keepalive_timeout: 65
  19. # nginx_webroot_create: False
  20. nginx_ocsp: False
  21. nginx_worker_processes: auto
  22. nginx_manage_ipv6only: False
  23. # TODO: Replace [::]:443 to 443 and [::]:80 to 80 in site nginx config
  24. nginx__servers:
  25. - name: '{{ domain_name }}'
  26. type: php
  27. root: '/var/www/{{ site_name }}'
  28. public_dir_name: ''
  29. include_files_begin: '{{ nginx_includes_begin }}'
  30. options: 'set $upstream unix:/run/{{ php__version_preference[0] }}-fpm-www-data.sock;'
  31. location_list:
  32. - pattern: '/'
  33. locations:
  34. - pattern: '~ ^/*.-backend/'
  35. options: 'set $upstream unix:/run/{{ php__version_preference[0] }}-fpm-backend.sock;'
  36. options: try_files /index.html @october;
  37. - pattern: '@october'
  38. options: rewrite ^/.*$ /index.php last;
  39. - pattern: '~* ^(?!/index).*\.php$'
  40. options: return 403;
  41. php_options: |
  42. fastcgi_read_timeout 3000;
  43. php_upstream: $upstream
  44. #location ~ ^(?!.+\.php/)(?<script_name>.+\.php)$ {
  45. php_location_script_name: ~ ^(?<script_name>/index\.php)
  46. #location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
  47. php_location_path_info: ~ ^(?<script_name>/index\.php)(?<path_info>/.*)?
  48. pre_tasks:
  49. - name: Set filtered includes
  50. set_fact:
  51. nginx_includes_begin: "{{ (nginx_includes_begin | default([])) | union([item]) }}"
  52. when: item != omit
  53. loop:
  54. - "{{ (nginx_www_domain and nginx_www_redirect == 'www') | ternary('includes.d/www.conf', omit) }}"
  55. - "{{ (nginx_www_domain and nginx_www_redirect == 'non-www') | ternary('includes.d/non-www.conf', omit) }}"
  56. - includes.d/octobercms.conf
  57. - includes.d/staticfiles.conf
  58. - name: Copy OctoberCMS nginx conf includes and www redirect
  59. copy:
  60. src: etc/nginx/includes.d
  61. dest: /etc/nginx/
  62. mode: 0644
  63. post_tasks:
  64. - name: Default index.html
  65. template:
  66. src: var/www/site_name/index.html.j2
  67. dest: '/var/www/{{ site_name }}/index.html'
  68. mode: 0644
  69. owner: '{{ site_name }}'
  70. - name: Copy normalized.css
  71. template:
  72. src: var/www/site_name/normalize.css
  73. dest: '/var/www/{{ site_name }}/'
  74. mode: 0644
  75. owner: '{{ site_name }}'
  76. roles:
  77. # - role: keyring
  78. # tags: [ 'role::keyring', 'skip::keyring', 'role::nginx' ]
  79. # keyring__dependent_apt_keys:
  80. # - '{{ nginx__keyring__dependent_apt_keys }}'
  81. #
  82. # - role: apt_preferences
  83. # tags: [ 'role::apt_preferences', 'skip::apt_preferences' ]
  84. # apt_preferences__dependent_list:
  85. # - '{{ nginx__apt_preferences__dependent_list }}'
  86. #
  87. # - role: python
  88. # tags: [ 'role::python', 'skip::python' ]
  89. # python__dependent_packages3:
  90. # - '{{ nginx__python__dependent_packages3 }}'
  91. # python__dependent_packages2:
  92. # - '{{ nginx__python__dependent_packages2 }}'
  93. - role: nginx
  94. tags: [ 'role::nginx', 'skip::nginx' ]