Skip to content

Commit

Permalink
Create oonidata_airflow role
Browse files Browse the repository at this point in the history
* Add support for nginx reverse proxy
  • Loading branch information
hellais committed Dec 20, 2024
1 parent 9db74a7 commit 59fd0da
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 12 deletions.
3 changes: 1 addition & 2 deletions ansible/deploy-airflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
- data2.htz-fsn.prod.ooni.nu
become: true
roles:
# Comes from https://github.com/idealista/airflow-role
- {"role": "airflow"}
- oonidata_airflow
2 changes: 1 addition & 1 deletion ansible/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
name: idealista.clickhouse_role
- src: https://github.com/ooni/airflow-role.git
scm: git
name: airflow
name: ooni.airflow_role
2 changes: 1 addition & 1 deletion ansible/roles/dehydrated/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
dependencies:
- nginx-buster
- nginx
...

8 changes: 0 additions & 8 deletions ansible/roles/dehydrated/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@
tags: dehydrated
shell: systemctl reload nginx.service

- name: allow incoming TCP connections to Nginx on port 80
tags: dehydrated
blockinfile:
path: /etc/ooni/nftables/tcp/80.nft
create: yes
block: |
add rule inet filter input tcp dport 80 counter accept comment "incoming HTTP"
- name: reload nftables service
tags: dehydrated
shell: systemctl reload nftables.service
Expand Down
3 changes: 3 additions & 0 deletions ansible/roles/oonidata_airflow/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tls_cert_dir: /var/lib/dehydrated/certs
airflow_public_fqdn: "{{ inventory_hostname }}"
certbot_domains_extra: []
4 changes: 4 additions & 0 deletions ansible/roles/oonidata_airflow/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- name: Reload nginx
ansible.builtin.systemd_service:
name: nginx
state: reloaded
35 changes: 35 additions & 0 deletions ansible/roles/oonidata_airflow/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
- ansible.builtin.include_role:
name: ooni.airflow_role
tags:
- oonidata
- airflow
vars:
airflow_webserver_host: "127.0.0.1"
airflow_webserver_port: 8080
airflow_webserver_base_url: "https://{{ airflow_public_fqdn }}/airflow"

- ansible.builtin.include_role:
name: nginx
tags:
- oonidata
- nginx

- ansible.builtin.include_role:
name: dehydrated
tags:
- oonidata
- dehydrated
vars:
ssl_domains: "{{ [ airflow_public_fqdn ] + certbot_domains_extra }}"

- name: Setup airflow nginx config
ansible.builtin.template:
src: nginx-airflow.j2
dest: /etc/nginx/sites-enabled/02-airflow
owner: root
mode: "0655"
notify:
- Reload nginx
tags:
- oonidata
- config
40 changes: 40 additions & 0 deletions ansible/roles/oonidata_airflow/templates/nginx-airflow.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# ansible-managed in ooni/devops.git

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

server {
listen 443 ssl http2;

include /etc/nginx/ssl_intermediate.conf;

ssl_certificate {{ tls_cert_dir }}/{{ airflow_public_fqdn }}/fullchain.pem;
ssl_certificate_key {{ tls_cert_dir }}/{{ airflow_public_fqdn }}/privkey.pem;
ssl_trusted_certificate {{ tls_cert_dir }}/{{ airflow_public_fqdn }}/chain.pem;

server_name _;
access_log /var/log/nginx/{{ airflow_public_fqdn }}.access.log;
error_log /var/log/nginx/{{ airflow_public_fqdn }}.log warn;

add_header Access-Control-Allow-Origin *;

## Airflow reverse proxy
location /airflow {
proxy_pass http://127.0.0.1:8080;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

client_max_body_size 100M;

# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Scheme $scheme;
proxy_buffering off;
}
}

0 comments on commit 59fd0da

Please sign in to comment.