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.

123 lines
4.1 KiB

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