Difference between revisions of "Syncthing-share"

From wikipost
Jump to navigationJump to search
Line 92: Line 92:
 
<pre>
 
<pre>
 
systemctl enable syncthing@syncthing.service
 
systemctl enable syncthing@syncthing.service
 +
systemctl start syncthing@syncthing.service
 
</pre>
 
</pre>
 +
 +
 +
Syncthing is now running and the web admin console can be reached from http://localhost:8384/. However if we want to remotely access this web console we need to configure a reverse proxy for it.
 +
 +
===Setting up a reverse proxy with Nginx===
 +
 +
* install nginx
 +
 +
<pre>
 +
apt-get install nginx
 +
</pre>
 +
 +
write an nginx website configuration file for syncthing
 +
 +
<pre>
 +
vi /etc/nginx/conf.d/syncthing.conf
 +
===
 +
server {
 +
  listen 80;
 +
  server_name hosname.com;
 +
 +
  root /usr/share/nginx/syncthing;
 +
  access_log /var/log/nginx/syncthing.log;
 +
  error_log /var/log/nginx/syncthing.error.log;
 +
  location / {
 +
    proxy_pass http://127.0.0.1:8384;
 +
    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;
 +
  }
 +
}
 +
===
 +
 +
</pre>
 +
 +
 +
 +
* change the config file so we can get web-access to the service

Revision as of 09:58, 27 October 2019

This article shows how to set up a Syncthing share.


  • apt-get install samba syncthing


Samba setup

Because samba runs on Linux it's easier to manage samba user accounts when these users also exist as local users on the Linux system.

Furthermore, to apply permissions to all samba users in one go it is easier to create a linux group as well.


groupadd samba-users


  • mkdir /home/samba


  • mkdir /home/samba/share
  • chgrp samba-users /home/samba/share
  • chmod 775 /home/samba/share
  • mkdir /home/samba/syncthing
  • chgrp samba-users /home/samba/syncthing
  • chmod 775 /home/samba/syncthing


Add the user accounts you'll need for your samba server:

adduser --gecos joe
(+ enter new password)


Add the users to the samba-users group:

adduser joe samba-users


Create the samba users:

smbpasswd -a joe
(+ enter same password as in linux)


  • edit /etc/samba/smb.conf

at the end of the file, add these lines:

[share]
   comment = Samba Share
   path = /home/samba/share
   browseable = yes
   read only = no
   guest ok = no   
   valid users = @samba-users

You can now browse to \\<ip-address>\ with windows explorer where you will see the 'share' folder. Double-click on it and you will be presented with a login window, asking for credentials. Enter your user name and the password and you are now able to use the share for reading, writing and deleting files.


Syncthing Setup

  • create syncthing system account and home directory
useradd -r syncthing -m -d /home/syncthing


  • enable syncthing to run as a service (unit file in /lib/systemd/system/)
systemctl enable syncthing@syncthing.service
systemctl start syncthing@syncthing.service


Syncthing is now running and the web admin console can be reached from http://localhost:8384/. However if we want to remotely access this web console we need to configure a reverse proxy for it.

Setting up a reverse proxy with Nginx

  • install nginx
apt-get install nginx

write an nginx website configuration file for syncthing

vi /etc/nginx/conf.d/syncthing.conf
===
server {
  listen 80;
  server_name hosname.com;

  root /usr/share/nginx/syncthing;
  access_log /var/log/nginx/syncthing.log;
  error_log /var/log/nginx/syncthing.error.log;
  location / {
    proxy_pass http://127.0.0.1:8384;
    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;
  }
}
===


  • change the config file so we can get web-access to the service