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