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.

124 lines
3.9 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: |
  37. try_files /index.html @october
  38. set $upstream unix:/run/{{ php__version_preference[0] }}-fpm-backend.sock
  39. client_max_body_size 1000M
  40. options: try_files /index.html @october;
  41. - pattern: '@october'
  42. options: rewrite ^/.*$ /index.php last;
  43. - pattern: '~* ^(?!/index).*\.php$'
  44. options: return 403;
  45. php_options: |
  46. fastcgi_read_timeout 3000;
  47. php_upstream: $upstream
  48. #location ~ ^(?!.+\.php/)(?<script_name>.+\.php)$ {
  49. php_location_script_name: ~ ^(?<script_name>/index\.php)
  50. #location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
  51. php_location_path_info: ~ ^(?<script_name>/index\.php)(?<path_info>/.*)?
  52. pre_tasks:
  53. - name: Set filtered includes
  54. set_fact:
  55. nginx_includes_begin: "{{ (nginx_includes_begin | default([])) | union([item]) }}"
  56. when: item != omit
  57. loop:
  58. - "{{ (nginx_www_domain and nginx_www_redirect == 'www') | ternary('includes.d/www.conf', omit) }}"
  59. - "{{ (nginx_www_domain and nginx_www_redirect == 'non-www') | ternary('includes.d/non-www.conf', omit) }}"
  60. - includes.d/octobercms.conf
  61. - includes.d/staticfiles.conf
  62. - name: Copy OctoberCMS nginx conf includes and www redirect
  63. copy:
  64. src: etc/nginx/includes.d
  65. dest: /etc/nginx/
  66. mode: 0644
  67. - name: Copy map config for www/non-www redirects
  68. copy:
  69. src: etc/nginx/conf.d/map_tld_domain.conf
  70. dest: /etc/nginx/conf.d/
  71. mode: 0644
  72. post_tasks:
  73. - name: Default index.html
  74. template:
  75. src: var/www/site_name/index.html.j2
  76. dest: '/var/www/{{ site_name }}/index.html'
  77. mode: 0644
  78. owner: '{{ site_name }}'
  79. - name: Copy normalized.css
  80. template:
  81. src: var/www/site_name/normalize.css
  82. dest: '/var/www/{{ site_name }}/'
  83. mode: 0644
  84. owner: '{{ site_name }}'
  85. roles:
  86. # - role: keyring
  87. # tags: [ 'role::keyring', 'skip::keyring', 'role::nginx' ]
  88. # keyring__dependent_apt_keys:
  89. # - '{{ nginx__keyring__dependent_apt_keys }}'
  90. #
  91. # - role: apt_preferences
  92. # tags: [ 'role::apt_preferences', 'skip::apt_preferences' ]
  93. # apt_preferences__dependent_list:
  94. # - '{{ nginx__apt_preferences__dependent_list }}'
  95. #
  96. # - role: python
  97. # tags: [ 'role::python', 'skip::python' ]
  98. # python__dependent_packages3:
  99. # - '{{ nginx__python__dependent_packages3 }}'
  100. # python__dependent_packages2:
  101. # - '{{ nginx__python__dependent_packages2 }}'
  102. - role: nginx
  103. tags: [ 'role::nginx', 'skip::nginx' ]