From 1a647c1a7ab9b38b395b2114caa4fc7e9450224e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 19 Feb 2016 18:35:18 +0000 Subject: [PATCH] Allow hubzilla on onion only, no onion address for typical installs --- src/freedombone | 175 ++++++++++++++++++++++++------------------------ 1 file changed, 86 insertions(+), 89 deletions(-) diff --git a/src/freedombone b/src/freedombone index 3f854d40..32ea8bd5 100755 --- a/src/freedombone +++ b/src/freedombone @@ -9059,10 +9059,6 @@ function install_hubzilla { if [ ! $HUBZILLA_DOMAIN_NAME ]; then return fi - # For now it probably won't install as onion-only. This might change in future - if [[ $ONION_ONLY != "no" ]]; then - return - fi # update to a new commit if needed set_repo_commit /var/www/$HUBZILLA_DOMAIN_NAME/htdocs "Hubzilla commit" "$HUBZILLA_COMMIT" $HUBZILLA_REPO @@ -9242,83 +9238,82 @@ function install_hubzilla { echo '}' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME else - echo -n '' > /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo 'server {' > /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo " listen 127.0.0.1:${HUBZILLA_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo " root /var/www/$HUBZILLA_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo " server_name $HUBZILLA_DOMAIN_NAME;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo " error_log /var/log/nginx/${HUBZILLA_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' index index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' charset utf-8;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' client_max_body_size 20m;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' client_body_buffer_size 128k;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' access_log off;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' limit_conn conn_limit_per_ip 10;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' limit_req zone=req_limit_per_ip burst=10 nodelay;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' add_header X-Frame-Options DENY;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' add_header X-Content-Type-Options nosniff;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' add_header Strict-Transport-Security max-age=15768000;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' location / {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo " # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' allow all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # statically serve these file types when possible' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # otherwise fall back to front controller' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # allow browser to cache them' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' expires 30d;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # block these file types' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # or a unix socket' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' location ~* \.php$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # Zero-day exploit defense.' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo " # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo " # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo " # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo " # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # With php5-cgi alone:' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # With php5-fpm:' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' include fastcgi_params;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' fastcgi_index index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' fastcgi_read_timeout 300;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' location ~ /\. {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME + echo '}' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME fi - echo 'server {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo " listen 127.0.0.1:${HUBZILLA_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo " root /var/www/$HUBZILLA_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo " server_name $HUBZILLA_DOMAIN_NAME;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo " error_log /var/log/nginx/${HUBZILLA_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' index index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' charset utf-8;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' client_max_body_size 20m;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' client_body_buffer_size 128k;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' access_log off;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' limit_conn conn_limit_per_ip 10;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' limit_req zone=req_limit_per_ip burst=10 nodelay;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' add_header X-Frame-Options DENY;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' add_header X-Content-Type-Options nosniff;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' add_header Strict-Transport-Security max-age=15768000;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' location / {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo " # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' allow all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # statically serve these file types when possible' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # otherwise fall back to front controller' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # allow browser to cache them' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' expires 30d;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # block these file types' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # or a unix socket' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' location ~* \.php$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # Zero-day exploit defense.' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo " # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo " # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo " # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo " # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # With php5-cgi alone:' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # With php5-fpm:' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' include fastcgi_params;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' fastcgi_index index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' fastcgi_read_timeout 300;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' location ~ /\. {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME - echo '}' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME configure_php @@ -9404,21 +9399,23 @@ function install_hubzilla { nginx_ensite $HUBZILLA_DOMAIN_NAME - HUBZILLA_ONION_HOSTNAME=$(add_onion_service hubzilla 80 ${HUBZILLA_ONION_PORT}) + HUBZILLA_ONION_HOSTNAME= + if [[ $ONION_ONLY != "no" ]]; then + HUBZILLA_ONION_HOSTNAME=$(add_onion_service hubzilla 80 ${HUBZILLA_ONION_PORT}) + if ! grep -q "Hubzilla onion domain" /home/$MY_USERNAME/README; then + echo "Hubzilla onion domain: ${HUBZILLA_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README + echo '' >> /home/$MY_USERNAME/README + chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README + chmod 600 /home/$MY_USERNAME/README + fi + echo "Hubzilla onion domain:${HUBZILLA_ONION_HOSTNAME}" >> $COMPLETION_FILE + fi systemctl restart php5-fpm systemctl restart nginx systemctl restart cron - if ! grep -q "Hubzilla onion domain" /home/$MY_USERNAME/README; then - echo "Hubzilla onion domain: ${HUBZILLA_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README - echo '' >> /home/$MY_USERNAME/README - chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README - chmod 600 /home/$MY_USERNAME/README - fi - echo "Hubzilla domain:${HUBZILLA_DOMAIN_NAME}" >> $COMPLETION_FILE - echo "Hubzilla onion domain:${HUBZILLA_ONION_HOSTNAME}" >> $COMPLETION_FILE echo 'install_hubzilla' >> $COMPLETION_FILE }