Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
freedombone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Context Sensitive Group
freedombone
Commits
883d4837
Commit
883d4837
authored
8 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
nginx config for matrix
parent
39544a6b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/freedombone-app-matrix
+101
-1
101 additions, 1 deletion
src/freedombone-app-matrix
with
101 additions
and
1 deletion
src/freedombone-app-matrix
+
101
−
1
View file @
883d4837
...
...
@@ -47,6 +47,103 @@ matrix_variables=(ONION_ONLY
MATRIX_SECRET
DEFAULT_DOMAIN_NAME
)
function
matrix_nginx
{
matrix_proxy_str
=
'
location /matrix {
proxy_pass https://localhost:8448;
proxy_buffering on;
}'
if
[
!
-f
/etc/nginx/sites-available/
${
DEFAULT_DOMAIN_NAME
}
]
;
then
matrix_nginx_site
=
/etc/nginx/sites-available/
$DEFAULT_DOMAIN_NAME
if
[[
$ONION_ONLY
==
"no"
]]
;
then
function_check nginx_http_redirect
nginx_http_redirect
$DEFAULT_DOMAIN_NAME
echo
'server {'
>>
$matrix_nginx_site
echo
' listen 443 ssl;'
>>
$matrix_nginx_site
echo
' listen [::]:443 ssl;'
>>
$matrix_nginx_site
echo
" server_name
$DEFAULT_DOMAIN_NAME
;"
>>
$matrix_nginx_site
echo
''
>>
$matrix_nginx_site
echo
' # Security'
>>
$matrix_nginx_site
function_check nginx_ssl
nginx_ssl
$DEFAULT_DOMAIN_NAME
function_check nginx_disable_sniffing
nginx_disable_sniffing
$DEFAULT_DOMAIN_NAME
echo
' add_header Strict-Transport-Security max-age=15768000;'
>>
$matrix_nginx_site
echo
''
>>
$matrix_nginx_site
echo
' # Logs'
>>
$matrix_nginx_site
echo
' access_log /dev/null;'
>>
$matrix_nginx_site
echo
' error_log /dev/null;'
>>
$matrix_nginx_site
echo
''
>>
$matrix_nginx_site
echo
' # Root'
>>
$matrix_nginx_site
echo
" root /var/www/
$DEFAULT_DOMAIN_NAME
/htdocs;"
>>
$matrix_nginx_site
echo
''
>>
$matrix_nginx_site
echo
' # Index'
>>
$matrix_nginx_site
echo
' index index.html;'
>>
$matrix_nginx_site
echo
''
>>
$matrix_nginx_site
echo
' # Location'
>>
$matrix_nginx_site
echo
' location / {'
>>
$matrix_nginx_site
function_check nginx_limits
nginx_limits
$DEFAULT_DOMAIN_NAME
'15m'
echo
' }'
>>
$matrix_nginx_site
echo
''
>>
$matrix_nginx_site
echo
' # Restrict access that is unnecessary anyway'
>>
$matrix_nginx_site
echo
' location ~ /\.(ht|git) {'
>>
$matrix_nginx_site
echo
' deny all;'
>>
$matrix_nginx_site
echo
' }'
>>
$matrix_nginx_site
echo
'}'
>>
$matrix_nginx_site
else
echo
-n
''
>
$matrix_nginx_site
fi
echo
'server {'
>>
$matrix_nginx_site
echo
" listen 127.0.0.1:
$MATRIX_PORT
default_server;"
>>
$matrix_nginx_site
echo
" server_name
$DEFAULT_DOMAIN_NAME
;"
>>
$matrix_nginx_site
echo
''
>>
$matrix_nginx_site
function_check nginx_disable_sniffing
nginx_disable_sniffing
$DEFAULT_DOMAIN_NAME
echo
''
>>
$matrix_nginx_site
echo
' # Logs'
>>
$matrix_nginx_site
echo
' access_log /dev/null;'
>>
$matrix_nginx_site
echo
' error_log /dev/null;'
>>
$matrix_nginx_site
echo
''
>>
$matrix_nginx_site
echo
' # Root'
>>
$matrix_nginx_site
echo
" root /var/www/
$DEFAULT_DOMAIN_NAME
/htdocs;"
>>
$matrix_nginx_site
echo
''
>>
$matrix_nginx_site
echo
' # Location'
>>
$matrix_nginx_site
echo
' location / {'
>>
$matrix_nginx_site
function_check nginx_limits
nginx_limits
$DEFAULT_DOMAIN_NAME
'15m'
echo
' }'
>>
$matrix_nginx_site
echo
''
>>
$matrix_nginx_site
echo
' # Fancy URLs'
>>
$matrix_nginx_site
echo
' location @matrix {'
>>
$matrix_nginx_site
echo
' rewrite ^(.*)$ /index.php?p=$1 last;'
>>
$matrix_nginx_site
echo
' }'
>>
$matrix_nginx_site
echo
''
>>
$matrix_nginx_site
echo
' # Restrict access that is unnecessary anyway'
>>
$matrix_nginx_site
echo
' location ~ /\.(ht|git) {'
>>
$matrix_nginx_site
echo
' deny all;'
>>
$matrix_nginx_site
echo
' }'
>>
$matrix_nginx_site
echo
'}'
>>
$matrix_nginx_site
if
[
!
-f
/etc/ssl/certs/
${
DEFAULT_DOMAIN_NAME
}
.pem
]
;
then
function_check create_site_certificate
create_site_certificate
$DEFAULT_DOMAIN_NAME
'yes'
fi
nginx_ensite
$DEFAULT_DOMAIN_NAME
fi
if
!
grep
'localhost:8448'
/etc/nginx/sites-available/
${
DEFAULT_DOMAIN_NAME
}
;
then
sed
"s|:443 ssl;|:443 ssl;
${
matrix_proxy_str
}
|g"
/etc/nginx/sites-available/
${
DEFAULT_DOMAIN_NAME
}
sed
"s| default_server;| default_server;
${
matrix_proxy_str
}
|g"
/etc/nginx/sites-available/
${
DEFAULT_DOMAIN_NAME
}
fi
systemctl restart nginx
}
function
matrix_generate_synapse_file
{
local
filepath
=
"
${
1
}
"
...
...
@@ -130,10 +227,11 @@ function add_user_matrix {
${
PROJECT_NAME
}
-pass
-u
$new_username
-a
matrix
-p
"
$new_user_password
"
read_config_param
'MATRIX_SECRET'
matrix_nginx
if
[
-f
/var/lib/matrix/.synapse/bin/activate
]
;
then
source
/var/lib/matrix/.synapse/bin/activate
fi
register_new_matrix_user
-c
${
MATRIX_DATA_DIR
}
/homeserver.yaml https://
localhost:
${
MATRIX_PORT
}
-u
"
${
new_username
}
"
-p
"
${
new_user_password
}
"
-a
register_new_matrix_user
-c
${
MATRIX_DATA_DIR
}
/homeserver.yaml https://
${
DEFAULT_DOMAIN_NAME
}
/matrix
-u
"
${
new_username
}
"
-p
"
${
new_user_password
}
"
-a
if
[
!
"
$?
"
=
"0"
]
;
then
echo
'1'
else
...
...
@@ -382,6 +480,8 @@ function install_matrix {
rm
-f
${
MATRIX_DATA_DIR
}
/.procmailrc
rm
-f
${
MATRIX_DATA_DIR
}
/.emacs-mutt
matrix_nginx
if
[[
$(
add_user_matrix
"
${
MY_USERNAME
}
"
"
${
MATRIX_PASSWORD
}
"
)
!=
"0"
]]
;
then
echo
$'Failed to add matrix admin user'
;
exit
879352
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment