|  | @@ -330,6 +330,10 @@ function install_cryptpad_main {
 | 
	
		
			
			| 330 | 330 |  
 | 
	
		
			
			| 331 | 331 |          echo '  add_header Strict-Transport-Security max-age=15768000;' >> $cryptpad_nginx_site
 | 
	
		
			
			| 332 | 332 |          echo '' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 333 | +        echo '  if ($uri = /pad/inner.html) {' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 334 | +        echo "    set \$scriptSrc \"'self' 'unsafe-eval' 'unsafe-inline'\";" >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 335 | +        echo '  }' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 336 | +        echo '' >> $cryptpad_nginx_site
 | 
	
		
			
			| 333 | 337 |          echo '  # Logs' >> $cryptpad_nginx_site
 | 
	
		
			
			| 334 | 338 |          echo '  access_log /dev/null;' >> $cryptpad_nginx_site
 | 
	
		
			
			| 335 | 339 |          echo '  error_log /dev/null;' >> $cryptpad_nginx_site
 | 
	
	
		
			
			|  | @@ -372,14 +376,14 @@ function install_cryptpad_main {
 | 
	
		
			
			| 372 | 376 |          echo '    rewrite ^(.*)$ $1/ redirect;' >> $cryptpad_nginx_site
 | 
	
		
			
			| 373 | 377 |          echo '  }' >> $cryptpad_nginx_site
 | 
	
		
			
			| 374 | 378 |          echo '' >> $cryptpad_nginx_site
 | 
	
		
			
			| 375 |  | -        echo '  try_files $uri $uri/index.html /customize/$uri;' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 379 | +        echo '  try_files /www/$uri /www/$uri/index.html /customize/$uri;' >> $cryptpad_nginx_site
 | 
	
		
			
			| 376 | 380 |          echo '}' >> $cryptpad_nginx_site
 | 
	
		
			
			| 377 | 381 |      else
 | 
	
		
			
			| 378 | 382 |          echo -n '' > $cryptpad_nginx_site
 | 
	
		
			
			| 379 | 383 |      fi
 | 
	
		
			
			| 380 | 384 |      echo 'server {' >> $cryptpad_nginx_site
 | 
	
		
			
			| 381 |  | -    echo "    listen 127.0.0.1:$CRYPTPAD_ONION_PORT default_server;" >> $cryptpad_nginx_site
 | 
	
		
			
			| 382 |  | -    echo "    server_name $CRYPTPAD_ONION_HOSTNAME;" >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 385 | +    echo "  listen 127.0.0.1:$CRYPTPAD_ONION_PORT default_server;" >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 386 | +    echo "  server_name $CRYPTPAD_ONION_HOSTNAME;" >> $cryptpad_nginx_site
 | 
	
		
			
			| 383 | 387 |      echo '' >> $cryptpad_nginx_site
 | 
	
		
			
			| 384 | 388 |      echo '  # Logs' >> $cryptpad_nginx_site
 | 
	
		
			
			| 385 | 389 |      echo '  access_log /dev/null;' >> $cryptpad_nginx_site
 | 
	
	
		
			
			|  | @@ -390,6 +394,16 @@ function install_cryptpad_main {
 | 
	
		
			
			| 390 | 394 |      echo '' >> $cryptpad_nginx_site
 | 
	
		
			
			| 391 | 395 |      echo '  index index.html;' >> $cryptpad_nginx_site
 | 
	
		
			
			| 392 | 396 |      echo '' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 397 | +    echo '  add_header X-XSS-Protection "1; mode=block";' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 398 | +    echo '  add_header X-Content-Type-Options nosniff;' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 399 | +    echo '  add_header X-Frame-Options SAMEORIGIN;' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 400 | +    echo '' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 401 | +    echo '  if ($uri = /pad/inner.html) {' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 402 | +    echo "    set \$scriptSrc \"'self' 'unsafe-eval' 'unsafe-inline'\";" >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 403 | +    echo '  }' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 404 | +    echo '' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 405 | +    echo "  add_header Content-Security-Policy \"default-src http:; script-src http: 'unsafe-inline'; style-src http: 'unsafe-inline'; img-src data: * blob: font-src self\";" >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 406 | +    echo '' >> $cryptpad_nginx_site
 | 
	
		
			
			| 393 | 407 |      echo '  location = /cryptpad_websocket {' >> $cryptpad_nginx_site
 | 
	
		
			
			| 394 | 408 |      echo "    proxy_pass http://localhost:$CRYPTPAD_PORT;" >> $cryptpad_nginx_site
 | 
	
		
			
			| 395 | 409 |      echo '    proxy_set_header X-Real-IP $remote_addr;' >> $cryptpad_nginx_site
 | 
	
	
		
			
			|  | @@ -423,10 +437,11 @@ function install_cryptpad_main {
 | 
	
		
			
			| 423 | 437 |      echo '    rewrite ^(.*)$ $1/ redirect;' >> $cryptpad_nginx_site
 | 
	
		
			
			| 424 | 438 |      echo '  }' >> $cryptpad_nginx_site
 | 
	
		
			
			| 425 | 439 |      echo '' >> $cryptpad_nginx_site
 | 
	
		
			
			| 426 |  | -    echo '  try_files $uri $uri/index.html /customize/$uri;' >> $cryptpad_nginx_site
 | 
	
		
			
			|  | 440 | +    echo '  try_files /www/$uri /www/$uri/index.html /customize/$uri;' >> $cryptpad_nginx_site
 | 
	
		
			
			| 427 | 441 |      echo '}' >> $cryptpad_nginx_site
 | 
	
		
			
			| 428 | 442 |  
 | 
	
		
			
			| 429 | 443 |      sed -i 's|DENY;|SAMEORIGIN;|g' $cryptpad_nginx_site
 | 
	
		
			
			|  | 444 | +    sed -i "s|Content-Security-Policy.*|Content-Security-Policy \"default-src http:; script-src http: 'unsafe-inline'; style-src http: 'unsafe-inline'; img-src data: * blob: font-src self\";|g" $cryptpad_nginx_site
 | 
	
		
			
			| 430 | 445 |  
 | 
	
		
			
			| 431 | 446 |      function_check create_site_certificate
 | 
	
		
			
			| 432 | 447 |      create_site_certificate $CRYPTPAD_DOMAIN_NAME 'yes'
 | 
	
	
		
			
			|  | @@ -463,7 +478,6 @@ function install_cryptpad {
 | 
	
		
			
			| 463 | 478 |      fi
 | 
	
		
			
			| 464 | 479 |  
 | 
	
		
			
			| 465 | 480 |      sed -i "s|httpPort:.*|httpPort: $CRYPTPAD_PORT,|g" config.js
 | 
	
		
			
			| 466 |  | -    sed -i "s|websocketPath:.*|websocketPath: '/',|g" config.js
 | 
	
		
			
			| 467 | 481 |      sed -i "s|// domain:|domain:|g" config.js
 | 
	
		
			
			| 468 | 482 |      sed -i 's|openFileLimit:.*|openFileLimit: 1024,|g' config.js
 | 
	
		
			
			| 469 | 483 |      if [[ $ONION_ONLY == 'no' ]]; then
 | 
	
	
		
			
			|  | @@ -471,6 +485,12 @@ function install_cryptpad {
 | 
	
		
			
			| 471 | 485 |      else
 | 
	
		
			
			| 472 | 486 |          sed -i "s|domain:.*|domain: 'http://$CRYPTPAD_ONION_HOSTNAME',|g" config.js
 | 
	
		
			
			| 473 | 487 |      fi
 | 
	
		
			
			|  | 488 | +    #if [[ $ONION_ONLY != 'no' ]]; then
 | 
	
		
			
			|  | 489 | +    #    sed -i "/module.exports/a ]," config.js
 | 
	
		
			
			|  | 490 | +    #    sed -i "/module.exports/a '\/etc\/ssl\/private\/${CRYPTPAD_DOMAIN_NAME}.key'" config.js
 | 
	
		
			
			|  | 491 | +    #    sed -i "/module.exports/a '\/etc\/ssl\/certs\/${CRYPTPAD_DOMAIN_NAME}.pem'" config.js
 | 
	
		
			
			|  | 492 | +    #    sed -i "/module.exports/a privKeyAndCertFiles: [" config.js
 | 
	
		
			
			|  | 493 | +    #fi
 | 
	
		
			
			| 474 | 494 |  
 | 
	
		
			
			| 475 | 495 |      chown -R cryptpad:cryptpad $CRYPTPAD_DIR
 | 
	
		
			
			| 476 | 496 |  
 | 
	
	
		
			
			|  | @@ -481,11 +501,12 @@ function install_cryptpad {
 | 
	
		
			
			| 481 | 501 |      echo 'After=network.target' >> /etc/systemd/system/cryptpad.service
 | 
	
		
			
			| 482 | 502 |      echo '' >> /etc/systemd/system/cryptpad.service
 | 
	
		
			
			| 483 | 503 |      echo '[Service]' >> /etc/systemd/system/cryptpad.service
 | 
	
		
			
			| 484 |  | -    echo 'Type=simple' >> /etc/systemd/system/cryptpad.service
 | 
	
		
			
			| 485 | 504 |      echo 'User=cryptpad' >> /etc/systemd/system/cryptpad.service
 | 
	
		
			
			| 486 | 505 |      echo 'Group=cryptpad' >> /etc/systemd/system/cryptpad.service
 | 
	
		
			
			| 487 | 506 |      echo "WorkingDirectory=$CRYPTPAD_DIR" >> /etc/systemd/system/cryptpad.service
 | 
	
		
			
			| 488 | 507 |      echo "ExecStart=/usr/local/bin/node $CRYPTPAD_DIR/server.js" >> /etc/systemd/system/cryptpad.service
 | 
	
		
			
			|  | 508 | +    echo 'Environment=PATH=/usr/bin:/usr/local/bin' >> /etc/systemd/system/cryptpad.service
 | 
	
		
			
			|  | 509 | +    echo 'Environment=NODE_ENV=production' >> /etc/systemd/system/cryptpad.service
 | 
	
		
			
			| 489 | 510 |      echo 'Restart=on-failure' >> /etc/systemd/system/cryptpad.service
 | 
	
		
			
			| 490 | 511 |      echo '' >> /etc/systemd/system/cryptpad.service
 | 
	
		
			
			| 491 | 512 |      echo '[Install]' >> /etc/systemd/system/cryptpad.service
 |