diff --git a/src/freedombone-app-cryptpad b/src/freedombone-app-cryptpad index e504a7bd..fe45bc06 100755 --- a/src/freedombone-app-cryptpad +++ b/src/freedombone-app-cryptpad @@ -103,8 +103,9 @@ function upgrade_cryptpad { cryptpad_create_config npm upgrade npm install - su -c 'echo "2" | bower update' - cryptpad - su -c 'bower install --config.interactive=false' - cryptpad + rm -rf $CRYPTPAD_DIR/.cache/bower + su -c './node_modules/bower/bin/bower install --config.interactive=false' - cryptpad + su -c './node_modules/bower/bin/bower update --config.interactive=false' - cryptpad cryptpad_generate_api_config chown -R cryptpad:cryptpad $CRYPTPAD_DIR @@ -407,11 +408,19 @@ function mesh_install_cryptpad { echo " try_files /customize/\$uri /customize.dist/\$uri;"; echo ' }'; echo ' location = /api/config {'; - echo ' default_type text/javascript;'; - echo ' rewrite ^.*$ /customize/api/config break;'; + echo " proxy_pass http://localhost:$CRYPTPAD_PORT;"; + echo " proxy_set_header X-Real-IP \$remote_addr;"; + echo " proxy_set_header Host \$host;"; + echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;"; echo ' }'; echo ''; echo ' location ^~ /blob/ {'; + echo ' add_header Cache-Control max-age=31536000;'; + echo " try_files \$uri =404;"; + echo ' }'; + echo ''; + echo ' location ^~ /datastore/ {'; + echo ' add_header Cache-Control max-age=0;'; echo " try_files \$uri =404;"; echo ' }'; echo ''; @@ -448,11 +457,11 @@ function mesh_install_cryptpad { cat < "$rootdir/usr/bin/install_cryptpad" #!/bin/bash -cd $CRYPTPAD_DIR +cd $CRYPTPAD_DIR || exit 358735 npm install --arch=$NPM_ARCH --build-from-source -npm install --arch=$NPM_ARCH -g bower@1.8.0 +npm install --arch=$NPM_ARCH bower@1.8.4 chown -R cryptpad:cryptpad $CRYPTPAD_DIR -su -c 'bower install' - cryptpad +su -c './node_modules/bower/bin/bower install --config.interactive=false' - cryptpad cp config.example.js config.js EOF chmod +x "$rootdir/usr/bin/install_cryptpad" @@ -575,11 +584,19 @@ function install_cryptpad_main { echo " try_files /customize/\$uri /customize.dist/\$uri;"; echo ' }'; echo ' location = /api/config {'; - echo ' default_type text/javascript;'; - echo ' rewrite ^.*$ /customize/api/config break;'; + echo " proxy_pass http://localhost:$CRYPTPAD_PORT;"; + echo " proxy_set_header X-Real-IP \$remote_addr;"; + echo " proxy_set_header Host \$host;"; + echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;"; echo ' }'; echo ''; echo ' location ^~ /blob/ {'; + echo ' add_header Cache-Control max-age=31536000;'; + echo " try_files \$uri =404;"; + echo ' }'; + echo ''; + echo ' location ^~ /datastore/ {'; + echo ' add_header Cache-Control max-age=0;'; echo " try_files \$uri =404;"; echo ' }'; echo ''; @@ -625,9 +642,10 @@ function install_cryptpad { cd $CRYPTPAD_DIR || exit 35483548 npm install - npm install -g bower@1.8.0 + npm install bower@1.8.4 chown -R cryptpad:cryptpad $CRYPTPAD_DIR - su -c 'bower install' - cryptpad + su -c './node_modules/bower/bin/bower install --config.interactive=false' - cryptpad + su -c './node_modules/bower/bin/bower update --config.interactive=false' - cryptpad cp config.example.js config.js if [ ! -f config.js ]; then echo $'Cryptpad config file not found'