Template for serving through an .onion address.
authorRomeo Papa <romeopapa@caramail.com>
Thu, 24 Mar 2016 20:48:04 +0000 (21:48 +0100)
committerRomeo Papa <romeopapa@caramail.com>
Thu, 24 Mar 2016 20:48:04 +0000 (21:48 +0100)
templates/web.onion.template.yml [new file with mode: 0644]

diff --git a/templates/web.onion.template.yml b/templates/web.onion.template.yml
new file mode 100644 (file)
index 0000000..6323cf4
--- /dev/null
@@ -0,0 +1,49 @@
+# Adds another server on port 80 for hidden service hosting
+
+run:
+  - exec:
+      cmd:
+        # Check DISCOURSE_ONION variable has been configured
+        - if [ -z "$DISCOURSE_ONION" ]; then echo "DISCOURSE_ONION ENV variable is required and has not been set."; exit 1; fi
+
+  - exec:
+      cmd:
+        # Copy default nginx file
+        - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/onion.conf"
+
+  # Remove duplicate entries that would crash the server
+  - replace:
+      filename: "/etc/nginx/conf.d/onion.conf"
+      from: /upstream[^\}]+\}/m
+      to: ""
+
+  - replace:
+      filename: "/etc/nginx/conf.d/onion.conf"
+      from: /map[^\}]+\}/m
+      to: ""
+
+  - replace:
+      filename: "/etc/nginx/conf.d/onion.conf"
+      from: /types[^\}]+\}/m
+      to: ""
+
+  - replace:
+      filename: "/etc/nginx/conf.d/onion.conf"
+      from: /proxy_cache_path.*$/
+      to: ""
+
+  - replace:
+      filename: "/etc/nginx/conf.d/onion.conf"
+      from: /log_format.*$/
+      to: ""
+
+  - replace:
+      filename: "/etc/nginx/conf.d/onion.conf"
+      from: /server_name.+$/
+      to: server_name $$ENV_DISCOURSE_ONION;
+
+  # Apply the same replacements done on web.template.yml to the nginx file
+  - replace:
+      filename: "/etc/nginx/conf.d/onion.conf"
+      from: /client_max_body_size.+$/
+      to: client_max_body_size $upload_size ;