Fix path & location issues with trailing slash and sub-folder instalation.
This commit is contained in:
parent
8db382e9ee
commit
ea9e5bb5c4
|
@ -1,4 +1,4 @@
|
|||
location PATHTOCHANGE {
|
||||
location YNH_WWW_LOCATION {
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
@ -6,8 +6,10 @@ location PATHTOCHANGE {
|
|||
}
|
||||
|
||||
location @searx {
|
||||
uwsgi_pass unix:///run/uwsgi/app/searx/socket;
|
||||
uwsgi_param SCRIPT_NAME 'YNH_WWW_PATH';
|
||||
include uwsgi_params;
|
||||
uwsgi_modifier1 30;
|
||||
uwsgi_pass unix:///run/uwsgi/app/searx/socket;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
location = PATHTOCHANGE { rewrite ^ PATHTOCHANGE/; }
|
||||
location PATHTOCHANGE {
|
||||
location = YNH_WWW_LOCATION { rewrite ^ YNH_WWW_LOCATION/; }
|
||||
|
||||
location YNH_WWW_LOCATION {
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
try_files $uri @searx; }
|
||||
try_files $uri @searx;
|
||||
}
|
||||
|
||||
location @searx {
|
||||
uwsgi_param SCRIPT_NAME PATHTOCHANGE;
|
||||
uwsgi_param SCRIPT_NAME 'YNH_WWW_PATH';
|
||||
include uwsgi_params;
|
||||
uwsgi_modifier1 30;
|
||||
uwsgi_pass unix:///run/uwsgi/app/searx/socket;
|
||||
|
|
|
@ -11,6 +11,18 @@ if [[ ! $? -eq 0 ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Path need a trailing slash, and location does not.
|
||||
# See conf/nginx.conf* usage
|
||||
location=$path
|
||||
if [[ ! $path == */ ]]; then
|
||||
# no trailing slash, so add it
|
||||
path=$path/
|
||||
fi
|
||||
if [[ ! "$location" == "/" ]]; then
|
||||
# remove possible trailing slash
|
||||
location=${location%/}
|
||||
fi
|
||||
|
||||
# Save specific settings
|
||||
sudo yunohost app setting searx is_public -v $is_public
|
||||
|
||||
|
@ -71,7 +83,8 @@ sudo cp ../conf/searx.ini /etc/uwsgi/apps-available/
|
|||
sudo ln -s /etc/uwsgi/apps-available/searx.ini /etc/uwsgi/apps-enabled/
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
sudo sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf*
|
||||
sed -i "s@YNH_WWW_LOCATION@$location@g" ../conf/nginx.conf*
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf*
|
||||
if [ "$path" != "/" ];
|
||||
then
|
||||
sudo cp ../conf/nginx.conf-noroot /etc/nginx/conf.d/$domain.d/searx.conf
|
||||
|
|
|
@ -5,8 +5,17 @@ domain=$(sudo yunohost app setting searx domain)
|
|||
path=$(sudo yunohost app setting searx path)
|
||||
is_public=$(sudo yunohost app setting searx is_public)
|
||||
|
||||
# Remove trailing "/" for next commands
|
||||
path=${path%/}
|
||||
# Path need a trailing slash, and location does not.
|
||||
# See conf/nginx.conf usage
|
||||
location=$path
|
||||
if [[ ! $path == */ ]]; then
|
||||
# no trailing slash, so add it
|
||||
path=$path/
|
||||
fi
|
||||
if [[ ! "$location" == "/" ]]; then
|
||||
# remove possible trailing slash
|
||||
location=${location%/}
|
||||
fi
|
||||
|
||||
# Check depends installation
|
||||
sudo apt-get install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python -y
|
||||
|
@ -62,7 +71,8 @@ sudo chown searx:searx -R $final_path
|
|||
sudo cp ../conf/searx.ini /etc/uwsgi/apps-available/
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
sudo sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf*
|
||||
sed -i "s@YNH_WWW_LOCATION@$location@g" ../conf/nginx.conf*
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf*
|
||||
if [ "$path" != "/" ];
|
||||
then
|
||||
sudo cp ../conf/nginx.conf-noroot /etc/nginx/conf.d/$domain.d/searx.conf
|
||||
|
|
Loading…
Reference in New Issue