Browse Source

Link to the administrator's keyring

Bob Mottram 8 years ago
parent
commit
5fbdc57fd3
1 changed files with 21 additions and 6 deletions
  1. 21
    6
      src/freedombone-app-mailpile

+ 21
- 6
src/freedombone-app-mailpile View File

319
         echo '  location / {' >> $mailpile_nginx_site
319
         echo '  location / {' >> $mailpile_nginx_site
320
         function_check nginx_limits
320
         function_check nginx_limits
321
         nginx_limits $MAILPILE_DOMAIN_NAME '15m'
321
         nginx_limits $MAILPILE_DOMAIN_NAME '15m'
322
-        echo "    proxy_pass        http://localhost:${MAILPILE_PORT}/;" >> $mailpile_nginx_site
323
-        echo '    proxy_set_header X-Forwarded-Host $host;' >> $mailpile_nginx_site
324
-        echo '    proxy_set_header X-Forwarded-Server $host;' >> $mailpile_nginx_site
322
+        echo '    rewrite /(.*) /$1 break;' >> $mailpile_nginx_site
323
+        echo '    proxy_set_header X-Real-IP $remote_addr;' >> $mailpile_nginx_site
325
         echo '    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $mailpile_nginx_site
324
         echo '    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $mailpile_nginx_site
325
+        echo '    proxy_set_header Host $http_host;' >> $mailpile_nginx_site
326
+        echo '    proxy_set_header X-NginX-Proxy true;' >> $mailpile_nginx_site
327
+        echo "    proxy_pass http://localhost:${MAILPILE_PORT};" >> $mailpile_nginx_site
328
+        echo '    proxy_redirect off;' >> $mailpile_nginx_site
326
         echo '  }' >> $mailpile_nginx_site
329
         echo '  }' >> $mailpile_nginx_site
327
         echo '' >> $mailpile_nginx_site
330
         echo '' >> $mailpile_nginx_site
328
         nginx_keybase ${MAILPILE_DOMAIN_NAME}
331
         nginx_keybase ${MAILPILE_DOMAIN_NAME}
347
     echo '  location / {' >> $mailpile_nginx_site
350
     echo '  location / {' >> $mailpile_nginx_site
348
     function_check nginx_limits
351
     function_check nginx_limits
349
     nginx_limits $MAILPILE_DOMAIN_NAME '15m'
352
     nginx_limits $MAILPILE_DOMAIN_NAME '15m'
350
-    echo "    proxy_pass        http://localhost:${MAILPILE_PORT}/;" >> $mailpile_nginx_site
351
-    echo '    proxy_set_header X-Forwarded-Host $host;' >> $mailpile_nginx_site
352
-    echo '    proxy_set_header X-Forwarded-Server $host;' >> $mailpile_nginx_site
353
+    echo '    rewrite /(.*) /$1 break;' >> $mailpile_nginx_site
354
+    echo '    proxy_set_header X-Real-IP $remote_addr;' >> $mailpile_nginx_site
353
     echo '    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $mailpile_nginx_site
355
     echo '    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $mailpile_nginx_site
356
+    echo '    proxy_set_header Host $http_host;' >> $mailpile_nginx_site
357
+    echo '    proxy_set_header X-NginX-Proxy true;' >> $mailpile_nginx_site
358
+    echo "    proxy_pass http://localhost:${MAILPILE_PORT};" >> $mailpile_nginx_site
359
+    echo '    proxy_redirect off;' >> $mailpile_nginx_site
354
     echo '  }' >> $mailpile_nginx_site
360
     echo '  }' >> $mailpile_nginx_site
355
     echo '' >> $mailpile_nginx_site
361
     echo '' >> $mailpile_nginx_site
356
     nginx_keybase ${MAILPILE_DOMAIN_NAME}
362
     nginx_keybase ${MAILPILE_DOMAIN_NAME}
396
     # if strict https is enforced then buttons don't work. This is probably a security bug
402
     # if strict https is enforced then buttons don't work. This is probably a security bug
397
     sed -i "s/Content-Security-Policy/d" $mailpile_nginx_site
403
     sed -i "s/Content-Security-Policy/d" $mailpile_nginx_site
398
 
404
 
405
+    # link to the administrator's keyring
406
+    if [ -d /var/www/$MAILPILE_DOMAIN_NAME/mail/.gnupg ]; then
407
+        mv /var/www/$MAILPILE_DOMAIN_NAME/mail/.gnupg /var/www/$MAILPILE_DOMAIN_NAME/mail/.gnupg_orig
408
+    fi
409
+    ln -s /home/$MY_USERNAME/.gnupg /var/www/$MAILPILE_DOMAIN_NAME/mail/
410
+    chown -R mailpile:mailpile /var/www/$MAILPILE_DOMAIN_NAME/mail/.gnupg
411
+    # unless the directory is executable we can't log in
412
+    chmod +x /var/www/$MAILPILE_DOMAIN_NAME/mail/.gnupg
413
+
399
     systemctl enable mailpile
414
     systemctl enable mailpile
400
     systemctl daemon-reload
415
     systemctl daemon-reload
401
     systemctl start mailpile
416
     systemctl start mailpile