Browse Source

Handling of turn port in nginx

Bob Mottram 8 years ago
parent
commit
433c502718
1 changed files with 14 additions and 5 deletions
  1. 14
    5
      src/freedombone-app-matrix

+ 14
- 5
src/freedombone-app-matrix View File

@@ -48,11 +48,16 @@ matrix_variables=(ONION_ONLY
48 48
                   DEFAULT_DOMAIN_NAME)
49 49
 
50 50
 function matrix_nginx {
51
-    matrix_proxy_str=' \
51
+    matrix_proxy_str=" \
52 52
     location /matrix { \
53
-        proxy_pass https://localhost:8448; \
53
+        proxy_pass https://localhost:${MATRIX_PORT}; \
54 54
         proxy_buffering on; \
55
-    }'
55
+    }"
56
+    turn_proxy_str=" \
57
+    location /turn { \
58
+        proxy_pass https://localhost:${TURN_PORT}; \
59
+        proxy_buffering on; \
60
+    }"
56 61
 
57 62
     if [ ! -f /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} ]; then
58 63
         matrix_nginx_site=/etc/nginx/sites-available/$DEFAULT_DOMAIN_NAME
@@ -131,10 +136,14 @@ function matrix_nginx {
131 136
         nginx_ensite $DEFAULT_DOMAIN_NAME
132 137
     fi
133 138
 
134
-    if ! grep 'localhost:8448' /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}; then
139
+    if ! grep "localhost:${MATRIX_PORT}" /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}; then
135 140
         sed -i "s|:443 ssl;|:443 ssl;${matrix_proxy_str}|g" /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
136 141
         sed -i "s| default_server;| default_server;${matrix_proxy_str}|g" /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
137 142
     fi
143
+    if ! grep 'localhost:${TURN_PORT}' /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}; then
144
+        sed -i "s|:443 ssl;|:443 ssl;${turn_proxy_str}|g" /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
145
+        sed -i "s| default_server;| default_server;${turn_proxy_str}|g" /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
146
+    fi
138 147
 
139 148
     systemctl restart nginx
140 149
 }
@@ -156,7 +165,7 @@ function matrix_configure_homeserver_yaml {
156 165
 
157 166
     local ymltemp="$(mktemp)"
158 167
 
159
-    awk -v TURNURIES="turn_uris: [\"turn:${DEFAULT_DOMAIN_NAME}:${TURN_PORT}?transport=udp\", \"turn:${DEFAULT_DOMAIN_NAME}:${TURN_PORT}?transport=tcp\"]" \
168
+    awk -v TURNURIES="turn_uris: [\"turn:${DEFAULT_DOMAIN_NAME}/turn?transport=udp\", \"turn:${DEFAULT_DOMAIN_NAME}/turn?transport=tcp\"]" \
160 169
         -v TURNSHAREDSECRET="turn_shared_secret: \"${turnkey}\"" \
161 170
         -v PIDFILE="pid_file: ${MATRIX_DATA_DIR}/homeserver.pid" \
162 171
         -v DATABASE="database: \"${MATRIX_DATA_DIR}/homeserver.db\"" \