-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add playbook for generating public node nginx config
- Loading branch information
1 parent
df00b8c
commit 362ef59
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
- name: Set public nodes templates | ||
hosts: "{{ hosts | default('monitoring') }}" | ||
|
||
tasks: | ||
- name: Generate RPC Nginx config | ||
become: true | ||
ansible.builtin.template: | ||
src: ../../templates/fullnode/nginx-rpc.j2 | ||
dest: "/etc/nginx/sites-enabled/rpc" | ||
mode: '0755' | ||
|
||
- name: Generate API Nginx config | ||
become: true | ||
ansible.builtin.template: | ||
src: ../../templates/fullnode/nginx-api.j2 | ||
dest: "/etc/nginx/sites-enabled/api" | ||
mode: '0755' | ||
|
||
- name: Generate Certbot template | ||
become: true | ||
ansible.builtin.shell: "sudo /snap/bin/certbot --nginx --agree-tos -m {{ certbot_email }} -n -d {{ api_domain }},{{ rpc_domain }}" | ||
args: | ||
executable: /bin/bash | ||
register: result | ||
changed_when: false | ||
|
||
- name: Verify Nginx config | ||
become: yes | ||
command: nginx -t | ||
changed_when: false | ||
|
||
- name: (Re)start Nginx | ||
become: true | ||
ansible.builtin.systemd: | ||
state: restarted | ||
name: nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
server { | ||
server_name {{ api_domain }}; | ||
|
||
location / { | ||
proxy_pass http://127.0.0.1:1317; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
} | ||
|
||
listen [::]:80; | ||
listen 80; | ||
return 404; # managed by Certbot | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
server { | ||
server_name {{ rpc_domain }}; | ||
|
||
location / { | ||
proxy_pass http://127.0.0.1:26657; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection $http_connection; | ||
} | ||
|
||
listen [::]:80; | ||
listen 80; | ||
return 404; # managed by Certbot | ||
} |