fix for onion addresses; added header to autodetect onion address on tor browser

This commit is contained in:
muppeth 2023-01-18 22:49:51 +01:00
parent 18cb8f5b37
commit 2c07b62947
Signed by: muppeth
GPG Key ID: 0EBC7B9848D04031
4 changed files with 11 additions and 7 deletions

View File

@ -20,5 +20,6 @@
- name: "[NGINX] - Create Vhosts configuration"
include_tasks: vhost.yml
loop: '{{ nginx_vhosts }}'

View File

@ -1,6 +1,11 @@
---
- name: '[ONION] - register onion address'
slurp:
src: "/var/lib/tor/{{ item.name }}/hostname"
register: "onion_address"
when: item.onion is defined and item.onion == 'true'
- name: "[NGINX] - Create vhosts"
- name: "[NGINX] - Set fact"
set_fact:
enable_tor: 'false'
@ -8,7 +13,6 @@
template:
src: etc/nginx/sites-available/{{ item.template }}.j2
dest: "{{ nginx_etc_dir }}/sites-available/{{ item.name }}"
with_items: "{{ nginx_vhosts }}"
notify:
- reload nginx
when: item.state is defined and item.state != 'delete'
@ -17,7 +21,6 @@
file:
path: "{{ nginx_etc_dir }}/sites-available/{{ item.name }}"
state: absent
with_items: "{{ nginx_vhosts }}"
notify:
- reload nginx
when: item.state is defined and item.state == 'delete'
@ -27,7 +30,6 @@
src: "{{ nginx_etc_dir }}/sites-available/{{ item.name }}"
dest: "{{ nginx_etc_dir }}/sites-enabled/{{ item.name }}"
state: link
with_items: "{{ nginx_vhosts }}"
notify:
- reload nginx
when: item.state is defined and item.state == 'enable'
@ -36,7 +38,6 @@
file:
path: "{{ nginx_etc_dir}}/sites-enabled/{{ item.name }}"
state: absent
with_items: "{{ nginx_vhosts }}"
notify:
- reload nginx
when: item.state is defined and (item.state == 'disable' or item.state == 'delete')
@ -53,7 +54,6 @@
template:
src: etc/nginx/sites-available/maintenance.j2
dest: "{{ nginx_etc_dir }}/sites-available/maintenance-{{ item.name }}"
with_items: "{{ nginx_vhosts }}"
notify:
- reload nginx
when: (item.state is defined) and (item.state != 'delete') and (item.maintenance is defined) and (item.maintenance == 'true')

View File

@ -52,6 +52,9 @@ server {
{% endblock %}
{% block headers %}
{% if enable_tor != 'true' and item.onion is defined and onion_address | length > 0 %}
add_header Onion-Location http://{{ onion_address.content | b64decode | trim }}$request_uri;
{% endif %}
{% if item.headers is defined and item.headers == 'none' %}
{% else %}
## HEADERS

View File

@ -71,7 +71,7 @@
{% for item in nginx_vhosts %}
{% if item.onion is defined and item.onion == 'true' %}
HiddenServiceDir /var/lib/tor/{{ item.name }}/
HiddenServicePort {{ item.listen }} unix:/var/run/{{ item.name }}.sock
HiddenServicePort {{ item.torlisten }} unix:/var/run/{{ item.name }}.sock
{% endif %}
{% endfor %}