mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Move redirect to /yunohost/admin to a separate nginx conf file to allow customizing it more easily
This commit is contained in:
parent
f1bfc521ae
commit
ac9182d69f
3 changed files with 8 additions and 12 deletions
|
@ -26,6 +26,9 @@ do_init_regen() {
|
||||||
ynh_render_template "security.conf.inc" "${nginx_conf_dir}/security.conf.inc"
|
ynh_render_template "security.conf.inc" "${nginx_conf_dir}/security.conf.inc"
|
||||||
ynh_render_template "yunohost_admin.conf" "${nginx_conf_dir}/yunohost_admin.conf"
|
ynh_render_template "yunohost_admin.conf" "${nginx_conf_dir}/yunohost_admin.conf"
|
||||||
|
|
||||||
|
mkdir -p $nginx_conf_dir/default.d/
|
||||||
|
cp "redirect_to_admin.conf" $nginx_conf_dir/default.d/
|
||||||
|
|
||||||
# Restart nginx if conf looks good, otherwise display error and exit unhappy
|
# Restart nginx if conf looks good, otherwise display error and exit unhappy
|
||||||
nginx -t 2>/dev/null || { nginx -t; exit 1; }
|
nginx -t 2>/dev/null || { nginx -t; exit 1; }
|
||||||
systemctl restart nginx || { journalctl --no-pager --lines=10 -u nginx >&2; exit 1; }
|
systemctl restart nginx || { journalctl --no-pager --lines=10 -u nginx >&2; exit 1; }
|
||||||
|
@ -77,6 +80,8 @@ do_pre_regen() {
|
||||||
done
|
done
|
||||||
|
|
||||||
ynh_render_template "yunohost_admin.conf" "${nginx_conf_dir}/yunohost_admin.conf"
|
ynh_render_template "yunohost_admin.conf" "${nginx_conf_dir}/yunohost_admin.conf"
|
||||||
|
mkdir -p $nginx_conf_dir/default.d/
|
||||||
|
cp "redirect_to_admin.conf" $nginx_conf_dir/default.d/
|
||||||
|
|
||||||
# remove old domain conf files
|
# remove old domain conf files
|
||||||
conf_files=$(ls -1 /etc/nginx/conf.d \
|
conf_files=$(ls -1 /etc/nginx/conf.d \
|
||||||
|
|
3
data/templates/nginx/redirect_to_admin.conf
Normal file
3
data/templates/nginx/redirect_to_admin.conf
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
location / {
|
||||||
|
return 302 https://$http_host/yunohost/admin;
|
||||||
|
}
|
|
@ -2,14 +2,6 @@ server {
|
||||||
listen 80 default_server;
|
listen 80 default_server;
|
||||||
listen [::]:80 default_server;
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
location / {
|
|
||||||
return 302 https://$http_host/yunohost/admin;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /yunohost/admin {
|
|
||||||
return 301 https://$http_host$request_uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
include /etc/nginx/conf.d/default.d/*.conf;
|
include /etc/nginx/conf.d/default.d/*.conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +17,6 @@ server {
|
||||||
more_set_headers "Strict-Transport-Security : max-age=63072000; includeSubDomains; preload";
|
more_set_headers "Strict-Transport-Security : max-age=63072000; includeSubDomains; preload";
|
||||||
more_set_headers "Referrer-Policy : 'same-origin'";
|
more_set_headers "Referrer-Policy : 'same-origin'";
|
||||||
|
|
||||||
location / {
|
|
||||||
return 302 https://$http_host/yunohost/admin;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /yunohost {
|
location /yunohost {
|
||||||
# Block crawlers bot
|
# Block crawlers bot
|
||||||
if ($http_user_agent ~ (crawl|Googlebot|Slurp|spider|bingbot|tracker|click|parser|spider|facebookexternalhit) ) {
|
if ($http_user_agent ~ (crawl|Googlebot|Slurp|spider|bingbot|tracker|click|parser|spider|facebookexternalhit) ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue