vrtmrz / obsidian-livesync

MIT License
4.7k stars 151 forks source link

how to implement SSL #315

Open dzhl opened 11 months ago

dzhl commented 11 months ago

I like this tool very much, it solves my multi-terminal synchronization problem very well, but I don't know how to implement SSL, so that the data transfer will be more secure, I use the official docker to install, please teach me!

bytebility commented 10 months ago

Just add nginx to the front end as an https reverse proxy. I gave you a complete reference nginx conf file as below, you just substitute your real domain name and internal server IP. Also I assume your external https port is 55984. In addition, you should apply for an https certificate.

vi /etc/nginx/nginx.conf

user  nginx;
worker_processes  auto;
error_log   logs/error.log;
pid        /run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    client_max_body_size 50M;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log;
    sendfile        on;
    keepalive_timeout  65;

  server {
      listen        55984 ssl;
      server_name   youdomain.com;

      ssl_certificate     "/usr/local/nginx/conf/vhosts/keys/youdomain.com.crt";
      ssl_certificate_key "/usr/local/nginx/conf/vhosts/keys/youdomain.com.key";
      ssl_protocols  TLSv1.2 TLSv1.3;
      ssl_prefer_server_ciphers on;
      ssl_ciphers    "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA HIGH !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
      access_log     /var/log/nginx/couchdb.access.log;
      error_log        /var/log/nginx/couchdb.error.log;
      charset utf-8;

      location / {
        proxy_pass          http://your-internal-server-IP:5984;
        proxy_redirect      off;

        proxy_set_header    Host              $host;
        proxy_set_header    X-Real-IP         $remote_addr;
        proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto $scheme;
      }
   }
}