|
@@ -59,111 +59,113 @@ function matrix_nginx {
|
59
|
59
|
|
60
|
60
|
# append the matrix server to the web site config
|
61
|
61
|
matrix_nginx_site=/etc/nginx/sites-available/$DEFAULT_DOMAIN_NAME
|
62
|
|
- if [[ $ONION_ONLY == "no" ]]; then
|
63
|
|
- echo '# Matrix Server' >> $matrix_nginx_site
|
|
62
|
+ if ! grep "# End of Matrix Server" $matrix_nginx_site; then
|
|
63
|
+ if [[ $ONION_ONLY == "no" ]]; then
|
|
64
|
+ echo '# Matrix Server' >> $matrix_nginx_site
|
|
65
|
+ echo 'server {' >> $matrix_nginx_site
|
|
66
|
+ echo " listen ${MATRIX_HTTP_PORT} ssl;" >> $matrix_nginx_site
|
|
67
|
+ echo " listen [::]:${MATRIX_HTTP_PORT} ssl;" >> $matrix_nginx_site
|
|
68
|
+ echo " server_name ${DEFAULT_DOMAIN_NAME};" >> $matrix_nginx_site
|
|
69
|
+ echo '' >> $matrix_nginx_site
|
|
70
|
+ echo ' # Security' >> $matrix_nginx_site
|
|
71
|
+ function_check nginx_ssl
|
|
72
|
+ nginx_ssl ${DEFAULT_DOMAIN_NAME}
|
|
73
|
+
|
|
74
|
+ function_check nginx_disable_sniffing
|
|
75
|
+ nginx_disable_sniffing ${DEFAULT_DOMAIN_NAME}
|
|
76
|
+
|
|
77
|
+ echo ' add_header Strict-Transport-Security max-age=15768000;' >> $matrix_nginx_site
|
|
78
|
+ echo '' >> $matrix_nginx_site
|
|
79
|
+ echo ' # Logs' >> $matrix_nginx_site
|
|
80
|
+ echo ' access_log /dev/null;' >> $matrix_nginx_site
|
|
81
|
+ echo ' error_log /dev/null;' >> $matrix_nginx_site
|
|
82
|
+ echo '' >> $matrix_nginx_site
|
|
83
|
+ echo ' # Index' >> $matrix_nginx_site
|
|
84
|
+ echo ' index index.html;' >> $matrix_nginx_site
|
|
85
|
+ echo '' >> $matrix_nginx_site
|
|
86
|
+ echo ' # Location' >> $matrix_nginx_site
|
|
87
|
+ echo ' location / {' >> $matrix_nginx_site
|
|
88
|
+ function_check nginx_limits
|
|
89
|
+ nginx_limits ${DEFAULT_DOMAIN_NAME} '15m'
|
|
90
|
+ echo " proxy_pass http://localhost:${MATRIX_PORT};" >> $matrix_nginx_site
|
|
91
|
+ echo ' proxy_set_header X-Forwarded-For $remote_addr;' >> $matrix_nginx_site
|
|
92
|
+ echo ' }' >> $matrix_nginx_site
|
|
93
|
+ echo '}' >> $matrix_nginx_site
|
|
94
|
+ echo '' >> $matrix_nginx_site
|
|
95
|
+ echo 'server {' >> $matrix_nginx_site
|
|
96
|
+ echo " listen ${MATRIX_ID_HTTP_PORT} ssl;" >> $matrix_nginx_site
|
|
97
|
+ echo " listen [::]:${MATRIX_ID_HTTP_PORT} ssl;" >> $matrix_nginx_site
|
|
98
|
+ echo " server_name ${DEFAULT_DOMAIN_NAME};" >> $matrix_nginx_site
|
|
99
|
+ echo '' >> $matrix_nginx_site
|
|
100
|
+ echo ' # Security' >> $matrix_nginx_site
|
|
101
|
+ function_check nginx_ssl
|
|
102
|
+ nginx_ssl ${DEFAULT_DOMAIN_NAME}
|
|
103
|
+
|
|
104
|
+ function_check nginx_disable_sniffing
|
|
105
|
+ nginx_disable_sniffing ${DEFAULT_DOMAIN_NAME}
|
|
106
|
+
|
|
107
|
+ echo ' add_header Strict-Transport-Security max-age=15768000;' >> $matrix_nginx_site
|
|
108
|
+ echo '' >> $matrix_nginx_site
|
|
109
|
+ echo ' # Logs' >> $matrix_nginx_site
|
|
110
|
+ echo ' access_log /dev/null;' >> $matrix_nginx_site
|
|
111
|
+ echo ' error_log /dev/null;' >> $matrix_nginx_site
|
|
112
|
+ echo '' >> $matrix_nginx_site
|
|
113
|
+ echo ' # Index' >> $matrix_nginx_site
|
|
114
|
+ echo ' index index.html;' >> $matrix_nginx_site
|
|
115
|
+ echo '' >> $matrix_nginx_site
|
|
116
|
+ echo ' # Location' >> $matrix_nginx_site
|
|
117
|
+ echo ' location / {' >> $matrix_nginx_site
|
|
118
|
+ function_check nginx_limits
|
|
119
|
+ nginx_limits ${DEFAULT_DOMAIN_NAME} '15m'
|
|
120
|
+ echo " proxy_pass http://localhost:${MATRIX_ID_PORT};" >> $matrix_nginx_site
|
|
121
|
+ echo ' proxy_set_header X-Forwarded-For $remote_addr;' >> $matrix_nginx_site
|
|
122
|
+ echo ' }' >> $matrix_nginx_site
|
|
123
|
+ echo '}' >> $matrix_nginx_site
|
|
124
|
+ echo '' >> $matrix_nginx_site
|
|
125
|
+ else
|
|
126
|
+ echo '# Matrix Server' >> $matrix_nginx_site
|
|
127
|
+ fi
|
64
|
128
|
echo 'server {' >> $matrix_nginx_site
|
65
|
|
- echo " listen ${MATRIX_HTTP_PORT} ssl;" >> $matrix_nginx_site
|
66
|
|
- echo " listen [::]:${MATRIX_HTTP_PORT} ssl;" >> $matrix_nginx_site
|
67
|
|
- echo " server_name ${DEFAULT_DOMAIN_NAME};" >> $matrix_nginx_site
|
|
129
|
+ echo " listen 127.0.0.1:$MATRIX_ONION_PORT default_server;" >> $matrix_nginx_site
|
|
130
|
+ echo " server_name $DEFAULT_DOMAIN_NAME;" >> $matrix_nginx_site
|
68
|
131
|
echo '' >> $matrix_nginx_site
|
69
|
|
- echo ' # Security' >> $matrix_nginx_site
|
70
|
|
- function_check nginx_ssl
|
71
|
|
- nginx_ssl ${DEFAULT_DOMAIN_NAME}
|
72
|
|
-
|
73
|
132
|
function_check nginx_disable_sniffing
|
74
|
|
- nginx_disable_sniffing ${DEFAULT_DOMAIN_NAME}
|
75
|
|
-
|
76
|
|
- echo ' add_header Strict-Transport-Security max-age=15768000;' >> $matrix_nginx_site
|
|
133
|
+ nginx_disable_sniffing $DEFAULT_DOMAIN_NAME
|
77
|
134
|
echo '' >> $matrix_nginx_site
|
78
|
135
|
echo ' # Logs' >> $matrix_nginx_site
|
79
|
136
|
echo ' access_log /dev/null;' >> $matrix_nginx_site
|
80
|
137
|
echo ' error_log /dev/null;' >> $matrix_nginx_site
|
81
|
138
|
echo '' >> $matrix_nginx_site
|
82
|
|
- echo ' # Index' >> $matrix_nginx_site
|
83
|
|
- echo ' index index.html;' >> $matrix_nginx_site
|
84
|
|
- echo '' >> $matrix_nginx_site
|
85
|
139
|
echo ' # Location' >> $matrix_nginx_site
|
86
|
140
|
echo ' location / {' >> $matrix_nginx_site
|
87
|
141
|
function_check nginx_limits
|
88
|
|
- nginx_limits ${DEFAULT_DOMAIN_NAME} '15m'
|
|
142
|
+ nginx_limits $DEFAULT_DOMAIN_NAME '15m'
|
89
|
143
|
echo " proxy_pass http://localhost:${MATRIX_PORT};" >> $matrix_nginx_site
|
90
|
144
|
echo ' proxy_set_header X-Forwarded-For $remote_addr;' >> $matrix_nginx_site
|
91
|
145
|
echo ' }' >> $matrix_nginx_site
|
92
|
146
|
echo '}' >> $matrix_nginx_site
|
93
|
147
|
echo '' >> $matrix_nginx_site
|
94
|
148
|
echo 'server {' >> $matrix_nginx_site
|
95
|
|
- echo " listen ${MATRIX_ID_HTTP_PORT} ssl;" >> $matrix_nginx_site
|
96
|
|
- echo " listen [::]:${MATRIX_ID_HTTP_PORT} ssl;" >> $matrix_nginx_site
|
97
|
|
- echo " server_name ${DEFAULT_DOMAIN_NAME};" >> $matrix_nginx_site
|
|
149
|
+ echo " listen 127.0.0.1:$MATRIX_ID_ONION_PORT default_server;" >> $matrix_nginx_site
|
|
150
|
+ echo " server_name $DEFAULT_DOMAIN_NAME;" >> $matrix_nginx_site
|
98
|
151
|
echo '' >> $matrix_nginx_site
|
99
|
|
- echo ' # Security' >> $matrix_nginx_site
|
100
|
|
- function_check nginx_ssl
|
101
|
|
- nginx_ssl ${DEFAULT_DOMAIN_NAME}
|
102
|
|
-
|
103
|
152
|
function_check nginx_disable_sniffing
|
104
|
|
- nginx_disable_sniffing ${DEFAULT_DOMAIN_NAME}
|
105
|
|
-
|
106
|
|
- echo ' add_header Strict-Transport-Security max-age=15768000;' >> $matrix_nginx_site
|
|
153
|
+ nginx_disable_sniffing $DEFAULT_DOMAIN_NAME
|
107
|
154
|
echo '' >> $matrix_nginx_site
|
108
|
155
|
echo ' # Logs' >> $matrix_nginx_site
|
109
|
156
|
echo ' access_log /dev/null;' >> $matrix_nginx_site
|
110
|
157
|
echo ' error_log /dev/null;' >> $matrix_nginx_site
|
111
|
158
|
echo '' >> $matrix_nginx_site
|
112
|
|
- echo ' # Index' >> $matrix_nginx_site
|
113
|
|
- echo ' index index.html;' >> $matrix_nginx_site
|
114
|
|
- echo '' >> $matrix_nginx_site
|
115
|
159
|
echo ' # Location' >> $matrix_nginx_site
|
116
|
160
|
echo ' location / {' >> $matrix_nginx_site
|
117
|
161
|
function_check nginx_limits
|
118
|
|
- nginx_limits ${DEFAULT_DOMAIN_NAME} '15m'
|
|
162
|
+ nginx_limits $DEFAULT_DOMAIN_NAME '15m'
|
119
|
163
|
echo " proxy_pass http://localhost:${MATRIX_ID_PORT};" >> $matrix_nginx_site
|
120
|
164
|
echo ' proxy_set_header X-Forwarded-For $remote_addr;' >> $matrix_nginx_site
|
121
|
165
|
echo ' }' >> $matrix_nginx_site
|
122
|
166
|
echo '}' >> $matrix_nginx_site
|
123
|
|
- echo '' >> $matrix_nginx_site
|
124
|
|
- else
|
125
|
|
- echo '# Matrix Server' >> $matrix_nginx_site
|
|
167
|
+ echo '# End of Matrix Server' >> $matrix_nginx_site
|
126
|
168
|
fi
|
127
|
|
- echo 'server {' >> $matrix_nginx_site
|
128
|
|
- echo " listen 127.0.0.1:$MATRIX_ONION_PORT default_server;" >> $matrix_nginx_site
|
129
|
|
- echo " server_name $DEFAULT_DOMAIN_NAME;" >> $matrix_nginx_site
|
130
|
|
- echo '' >> $matrix_nginx_site
|
131
|
|
- function_check nginx_disable_sniffing
|
132
|
|
- nginx_disable_sniffing $DEFAULT_DOMAIN_NAME
|
133
|
|
- echo '' >> $matrix_nginx_site
|
134
|
|
- echo ' # Logs' >> $matrix_nginx_site
|
135
|
|
- echo ' access_log /dev/null;' >> $matrix_nginx_site
|
136
|
|
- echo ' error_log /dev/null;' >> $matrix_nginx_site
|
137
|
|
- echo '' >> $matrix_nginx_site
|
138
|
|
- echo ' # Location' >> $matrix_nginx_site
|
139
|
|
- echo ' location / {' >> $matrix_nginx_site
|
140
|
|
- function_check nginx_limits
|
141
|
|
- nginx_limits $DEFAULT_DOMAIN_NAME '15m'
|
142
|
|
- echo " proxy_pass http://localhost:${MATRIX_PORT};" >> $matrix_nginx_site
|
143
|
|
- echo ' proxy_set_header X-Forwarded-For $remote_addr;' >> $matrix_nginx_site
|
144
|
|
- echo ' }' >> $matrix_nginx_site
|
145
|
|
- echo '}' >> $matrix_nginx_site
|
146
|
|
- echo '' >> $matrix_nginx_site
|
147
|
|
- echo 'server {' >> $matrix_nginx_site
|
148
|
|
- echo " listen 127.0.0.1:$MATRIX_ID_ONION_PORT default_server;" >> $matrix_nginx_site
|
149
|
|
- echo " server_name $DEFAULT_DOMAIN_NAME;" >> $matrix_nginx_site
|
150
|
|
- echo '' >> $matrix_nginx_site
|
151
|
|
- function_check nginx_disable_sniffing
|
152
|
|
- nginx_disable_sniffing $DEFAULT_DOMAIN_NAME
|
153
|
|
- echo '' >> $matrix_nginx_site
|
154
|
|
- echo ' # Logs' >> $matrix_nginx_site
|
155
|
|
- echo ' access_log /dev/null;' >> $matrix_nginx_site
|
156
|
|
- echo ' error_log /dev/null;' >> $matrix_nginx_site
|
157
|
|
- echo '' >> $matrix_nginx_site
|
158
|
|
- echo ' # Location' >> $matrix_nginx_site
|
159
|
|
- echo ' location / {' >> $matrix_nginx_site
|
160
|
|
- function_check nginx_limits
|
161
|
|
- nginx_limits $DEFAULT_DOMAIN_NAME '15m'
|
162
|
|
- echo " proxy_pass http://localhost:${MATRIX_ID_PORT};" >> $matrix_nginx_site
|
163
|
|
- echo ' proxy_set_header X-Forwarded-For $remote_addr;' >> $matrix_nginx_site
|
164
|
|
- echo ' }' >> $matrix_nginx_site
|
165
|
|
- echo '}' >> $matrix_nginx_site
|
166
|
|
- echo '# End of Matrix Server' >> $matrix_nginx_site
|
167
|
169
|
|
168
|
170
|
systemctl restart nginx
|
169
|
171
|
systemctl restart turn
|