vue-deploy-nginx-proxy.yml 13.5 KB
---
- hosts: glb
  collections:
    - nginxinc.nginx_core
  tasks:
    - name: Install NGINX
      ansible.builtin.include_role:
        name: nginx
      vars:
        nginx_manage_repo: false
        nginx_install_from: os_repository

    - name: Configure NGINX
      ansible.builtin.include_role:
        name: nginx_config
      vars:
        nginx_config_http_template_enable: true
        nginx_config_http_template:
          - template_file: http/default.conf.j2
            deployment_location: /etc/nginx/conf.d/default.conf
            config:
              headers:  # Configure headers
                add_headers:  # Can be a dictionary or a list of dictionaries
                  - name: Content-Security-Policy # Required
                    value: 'upgrade-insecure-requests'  # Required
                    always: true  # Boolean 

              log:
                access:
                  - path: /var/log/nginx/access.log
                    format: main

              upstreams:
                - name: jbosseap
                  least_conn: true
                  servers:
                    - address: tlbi01.vue.gov.py:80

                - name: exportafacil
                  least_conn: true
                  servers:
                    - address: texportafacil01.vue.gov.py

                - name: sso
                  least_conn: true
                  servers:
                    - address: psso01.vue.gov.py

              ssl:
                certificate: /etc/letsencrypt/live/vueapp.test.vue.gov.py/fullchain.pem
                certificate_key: /etc/letsencrypt/live/vueapp.test.vue.gov.py/privkey.pem
                prefer_server_ciphers: true
                session_cache:
                  shared:
                    name: SSL
                    size: 10m
                session_timeout: 10m
                ssl_ciphers: PROFILE=SYSTEM

              servers:
                #vueapp
                - core:
                    listen:
                      - port: 80
                    server_name: vueapp.test.vue.gov.py
                  #Configure this to redirect to HTTPS, as of 26-oct-22, it should only be available for test
                  rewrite:
                    return:
                      code: 301
                      url: https://$host$request_uri

                - core:
                    client_max_body_size: 50m #Pueden subir max 7 archivos de 5mb c/u, verificar también en los JBoss EAP
                    client_body_buffer_size: 128k
                    listen:
                      - port: 443
                        http2: true
                        ssl: true
                    server_name: vueapp.test.vue.gov.py
                  locations:
                    - location: /
                      proxy:
                        pass: http://jbosseap/
                        set_header:
                          #Equivalent to ProxyPreserveHost on from Apache HTTPd Server. It is necessary to work with RH SSO correctly
                          - field: Host
                            value: $host
                          - field: X-Forwarded-For
                            value: $proxy_add_x_forwarded_for
                          - field: X-Real-IP
                            value: $remote_addr
                          - field: X-Forwarded-Proto
                            value: $scheme
                        #This next three values were increased for an app
                        read_timeout: 1200s
                        connect_timeout: 1200s
                        send_timeout: 1200s
                  sub_filter:
                    sub_filters:
                      #This is necessary for vue_firmador_api.war, to allow local connections to websocket in 127.0.0.1 with only http
                      - string: 'localhost'
                        replacement: '127.0.0.1'
                    once: false
                    types:
                      - text/css
                      - application/javascript

                #datos
                - core:
                    listen:
                      - port: 80
                    server_name: datos.test.vue.gov.py
                  #log:
                  #  access:
                  #    - path: /var/log/nginx/access.log
                  #      format: main
                  #Configure this to redirect to HTTPS, as of 26-oct-22, it should only be available for test
                  rewrite:
                    return:
                      code: 301
                      url: https://$host$request_uri
                - core:
                    client_max_body_size: 50m #Pueden subir max 7 archivos de 5mb c/u, verificar también en los JBoss EAP
                    client_body_buffer_size: 128k
                    listen:
                      - port: 443
                        http2: true
                        ssl: true
                    server_name: datos.test.vue.gov.py
                  #log:
                  #  access:
                  #    - path: /var/log/nginx/access.log
                  #      format: main
                  locations:
                    - location: /
                      proxy:
                        pass: http://jbosseap/
                        set_header:
                          #Equivalent to ProxyPreserveHost on from Apache HTTPd Server. It is necessary to work with RH SSO correctly
                          - field: Host
                            value: datos.vue.gov.py
                          - field: X-Forwarded-For
                            value: $proxy_add_x_forwarded_for
                          - field: X-Real-IP
                            value: $remote_addr
                          - field: X-Forwarded-Proto
                            value: $scheme
                        #This next three values were increased for an app
                        read_timeout: 1200s
                        connect_timeout: 1200s
                        send_timeout: 1200s

                #exportafacil
                - core:
                    listen:
                      - port: 80
                    server_name: exportafacil.test.vue.gov.py

                  #Configure this to redirect to HTTPS, as of 26-oct-22, it should only be available for test
                  rewrite:
                    return:
                      code: 301
                      url: https://$host$request_uri

                - core:
                    client_max_body_size: 50m #Pueden subir max 7 archivos de 5mb c/u, verificar también en los JBoss EAP
                    client_body_buffer_size: 128k
                    listen:
                      - port: 443
                        http2: true
                        ssl: true
                    server_name: exportafacil.test.vue.gov.py

                  locations:
                    - location: /
                      proxy:
                        pass: http://exportafacil/
                        set_header:
                          #Equivalent to ProxyPreserveHost on from Apache HTTPd Server. It is necessary to work with RH SSO correctly
                          - field: Host
                            value: $host
                          - field: X-Forwarded-For
                            value: $proxy_add_x_forwarded_for
                          - field: X-Real-IP
                            value: $remote_addr
                          - field: X-Forwarded-Proto
                            value: $scheme
                        #This next three values were increased for an app
                        read_timeout: 1200s
                        connect_timeout: 1200s
                        send_timeout: 1200s

                    - location: /backend-exporta-facil/
                      proxy:
                        pass: http://jbosseap/backend-exporta-facil/
                        set_header:
                          #Equivalent to ProxyPreserveHost on from Apache HTTPd Server. It is necessary to work with RH SSO correctly
                          - field: Host
                            value: $host
                          - field: X-Forwarded-For
                            value: $proxy_add_x_forwarded_for
                          - field: X-Real-IP
                            value: $remote_addr
                          - field: X-Forwarded-Proto
                            value: $scheme

                #sso
                - core:
                    listen:
                      - port: 80
                    server_name: sso.test.vue.gov.py
                  #Configure this to redirect to HTTPS, as of 26-oct-22, it should only be available for test
                  rewrite:
                    return:
                      code: 301
                      url: https://$host$request_uri
                - core:
                    client_max_body_size: 50m #Pueden subir max 7 archivos de 5mb c/u, verificar también en los JBoss EAP
                    client_body_buffer_size: 128k
                    listen:
                      - port: 443
                        http2: true
                        ssl: true
                    server_name: sso.test.vue.gov.py
                  locations:
                    - location: /
                      proxy:
                        pass: http://sso/
                        set_header:
                          #Equivalent to ProxyPreserveHost on from Apache HTTPd Server. It is necessary to work with RH SSO correctly
                          - field: Host
                            value: $host
                          - field: X-Forwarded-For
                            value: $proxy_add_x_forwarded_for
                          - field: X-Real-IP
                            value: $remote_addr
                          - field: X-Forwarded-Proto
                            value: $scheme
                        #This next three values were increased for an app
                        read_timeout: 1200s
                        connect_timeout: 1200s
                        send_timeout: 1200s

#              custom_directives:
                
#                - core:
#                    listen:
#                      - port: 8081
#                    server_name: localhost
#                  log:
#                    access:
#                      - path: /var/log/nginx/access.log
#                        format: main
#                  locations:
#                    - location: /
#                      core:
#                        root: /usr/share/nginx/html
#                        index: server_one.html
#                  sub_filter:
#                    sub_filters:
#                      - string: server_hostname
#                        replacement: $hostname
#                      - string: server_address
#                        replacement: $server_addr:$server_port
#                      - string: server_url
#                        replacement: $request_uri
#                      - string: remote_addr
#                        replacement: '$remote_addr:$remote_port'
#                      - string: server_date
#                        replacement: $time_local
#                      - string: client_browser
#                        replacement: $http_user_agent
#                      - string: request_id
#                        replacement: $request_id
#                      - string: nginx_version
#                        replacement: $nginx_version
#                      - string: document_root
#                        replacement: $document_root
#                      - string: proxied_for_ip
#                        replacement: $http_x_forwarded_for
#                    once: false
#                - core:
#                    listen:
#                      - port: 8082
#                    server_name: localhost
#                  log:
#                    access:
#                      - path: /var/log/nginx/access.log
#                        format: main
#                  locations:
#                    - location: /
#                      core:
#                        root: /usr/share/nginx/html
#                        index: server_two.html
#                  sub_filter:
#                    sub_filters:
#                      - string: server_hostname
#                        replacement: $hostname
#                      - string: server_address
#                        replacement: $server_addr:$server_port
#                      - string: server_url
#                        replacement: $request_uri
#                      - string: remote_addr
#                        replacement: '$remote_addr:$remote_port'
#                      - string: server_date
#                        replacement: $time_local
#                      - string: client_browser
#                        replacement: $http_user_agent
#                      - string: request_id
#                        replacement: $request_id
#                      - string: nginx_version
#                        replacement: $nginx_version
#                      - string: document_root
#                        replacement: $document_root
#                      - string: proxied_for_ip
#                        replacement: $http_x_forwarded_for
#                    once: false

        nginx_config_html_demo_template_enable: false
        nginx_config_html_demo_template:
          - template_file: www/index.html.j2
            deployment_location: /usr/share/nginx/html/server_one.html
            web_server_name: Ansible NGINX collection - Server one
          - template_file: www/index.html.j2
            deployment_location: /usr/share/nginx/html/server_two.html
            web_server_name: Ansible NGINX collection - Server two