Playbooks to a new Lilik
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.

72 lines
2.1 KiB

  1. ---
  2. - name: add https configs to nginx
  3. blockinfile:
  4. dest: /etc/nginx/nginx.conf
  5. block: |
  6. stream {
  7. map $ssl_preread_server_name $name {
  8. include /etc/nginx/map.conf.d/*.conf;
  9. }
  10. include /etc/nginx/upstream.conf.d/*.conf;
  11. log_format stream_routing '$remote_addr [$time_local] '
  12. 'with SNI name "$ssl_preread_server_name" '
  13. 'proxying to "$name" '
  14. '$protocol $status $bytes_sent $bytes_received '
  15. '$session_time';
  16. server {
  17. listen 150.217.18.45:443;
  18. ssl_preread on;
  19. proxy_pass $name;
  20. access_log /var/log/nginx/stream_443.log stream_routing;
  21. }
  22. }
  23. delegate_to: reverse_proxy
  24. - name: add http configs to nginx
  25. lineinfile:
  26. dest: /etc/nginx/nginx.conf
  27. insertafter: '^http {'
  28. line: 'include /etc/nginx/http.conf.d/*.conf;'
  29. delegate_to: reverse_proxy
  30. - name: Create the http.conf directory for nginx
  31. file:
  32. state: directory
  33. dest: "/etc/nginx/http.conf.d"
  34. delegate_to: reverse_proxy
  35. - name: Upload http to reverse proxy
  36. template:
  37. src: http.j2
  38. dest: "/etc/nginx/http.conf.d/http_{{ hostname }}.conf"
  39. delegate_to: reverse_proxy
  40. notify: reload nginx
  41. - name: Create the map.conf directory for nginx
  42. file:
  43. state: directory
  44. dest: "/etc/nginx/map.conf.d"
  45. delegate_to: reverse_proxy
  46. - name: Create the upstream.conf directory for nginx
  47. file:
  48. state: directory
  49. dest: "/etc/nginx/upstream.conf.d"
  50. delegate_to: reverse_proxy
  51. - name: Upload mappings to reverse proxy
  52. template:
  53. src: map.j2
  54. dest: "/etc/nginx/map.conf.d/map_{{ hostname }}.conf"
  55. delegate_to: reverse_proxy
  56. notify: reload nginx
  57. - name: Upload upstream to reverse proxy
  58. template:
  59. src: upstream.j2
  60. dest: "/etc/nginx/upstream.conf.d/upstream_{{ hostname }}.conf"
  61. delegate_to: reverse_proxy
  62. notify: reload nginx