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.

121 lines
3.8 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. - name: Copy map config for www/non-www redirects
  65. copy:
  66. src: etc/nginx/conf.d/map_tld_domain.conf
  67. dest: /etc/nginx/conf.d/
  68. mode: 0644
  69. post_tasks:
  70. - name: Default index.html
  71. template:
  72. src: var/www/site_name/index.html.j2
  73. dest: '/var/www/{{ site_name }}/index.html'
  74. mode: 0644
  75. owner: '{{ site_name }}'
  76. - name: Copy normalized.css
  77. template:
  78. src: var/www/site_name/normalize.css
  79. dest: '/var/www/{{ site_name }}/'
  80. mode: 0644
  81. owner: '{{ site_name }}'
  82. roles:
  83. # - role: keyring
  84. # tags: [ 'role::keyring', 'skip::keyring', 'role::nginx' ]
  85. # keyring__dependent_apt_keys:
  86. # - '{{ nginx__keyring__dependent_apt_keys }}'
  87. #
  88. # - role: apt_preferences
  89. # tags: [ 'role::apt_preferences', 'skip::apt_preferences' ]
  90. # apt_preferences__dependent_list:
  91. # - '{{ nginx__apt_preferences__dependent_list }}'
  92. #
  93. # - role: python
  94. # tags: [ 'role::python', 'skip::python' ]
  95. # python__dependent_packages3:
  96. # - '{{ nginx__python__dependent_packages3 }}'
  97. # python__dependent_packages2:
  98. # - '{{ nginx__python__dependent_packages2 }}'
  99. - role: nginx
  100. tags: [ 'role::nginx', 'skip::nginx' ]