diff --git a/conf/nginx.conf b/conf/nginx.conf index ce7e17f..6373d76 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,21 +1,6 @@ -location YNH_WWW_PATH { - alias YNH_WWW_ALIAS ; - - # Force https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - - index index.html index.htm index.php; - location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php5-fpm.sock; - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; - } - - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; +location YNH_WWW_PATH/ { + rewrite ^YNH_WWW_PATH$ YNH_WWW_PATH/ permanent; + proxy_pass http://localhost:8081/; + proxy_set_header Host $host; + proxy_buffering off; } diff --git a/conf/supervisor.conf b/conf/supervisor.conf new file mode 100644 index 0000000..0c0655d --- /dev/null +++ b/conf/supervisor.conf @@ -0,0 +1,5 @@ +[program:linuxdash] +directory=/var/www/linuxdash/ +command=python python-server.py +autostart=true +autorestart=true diff --git a/scripts/install b/scripts/install index 1a56909..b7a7397 100755 --- a/scripts/install +++ b/scripts/install @@ -20,9 +20,14 @@ sudo cp -a ../sources/* $final_path # Set permissions sudo chown -R www-data: $final_path +# Set as a service with supervisor +sudo apt-get -y -qq install supervisor +sudo cp ../conf/supervisor.conf /etc/supervisor/conf.d/$app.conf +sudo supervisorctl update +sudo supervisorctl restart $app + # Modify Nginx configuration file and copy it to Nginx conf directory sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf -sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf sudo cp ../conf/nginx.conf $nginxconf sudo chown root: $nginxconf diff --git a/scripts/remove b/scripts/remove index 5a1c2fb..1cf48eb 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,10 +1,15 @@ #!/bin/bash +app=linuxdash domain=$(sudo yunohost app setting linuxdash domain) # Remove sources and nginx configuration -sudo rm -rf /var/www/linuxdash -sudo rm -f /etc/nginx/conf.d/$domain.d/linuxdash.conf +sudo rm -rf /var/www/$app +sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf + +# Remove service +sudo supervisorctl stop $app +sudo rm -f /etc/supervisor/conf.d/$app.conf # Reload nginx configuration sudo service nginx reload