Skip to content

Configuration

Grigory Efimov edited this page Sep 23, 2024 · 4 revisions

Configuration via an env file

Warning

The .env file is generated automatically. It is based on the .env.common file, which is overridden or extended by variables from the .env.override file.

Version control

By default, we use "prod" image version for any-sync-* daemons. Also you can use "stage1" or "latest" verions:

# for use stage1 version
ln -F -s .env.override.stage1 .env.override
# for use latest version
ln -F -s .env.override.latest .env.override

# restart after changes
make restart

external listen host

By default, we use only the listen address 127.0.0.1, which is sufficient for running tests and a local client. If you need to connect external clients, please add "EXTERNAL_LISTEN_HOSTS" in .env.override file. Use spaces separation, multiline is not supported. For example:

EXTERNAL_LISTEN_HOSTS=<yourExternalIp1> <yourExternalIp2 ...

restart after changes

# restart after changes
make restart

custom storage directory

to change the file storage directory, you need to add the parameter STORAGE_DIR to the .env.override file

clean setup

echo "STORAGE_DIR=/path/to/your/directory" >> .env.override
make start

existing setup

if you have already run the self-hosted server, you need to transfer the files beforehand:

make stop
echo "STORAGE_DIR=/path/to/your/directory" >> .env.override
mv ./storage /path/to/your/directory
make start

Firewall

To ensure that the application works properly, the client must have access to the any-sync-* services (daemons).
You can retrieve the list of listening ports by using the following command:

grep 'ANY_SYNC_.*_PORT=' .env.default

Here is an example of the output:

ANY_SYNC_NODE_1_PORT=1001
ANY_SYNC_NODE_1_QUIC_PORT=1011
ANY_SYNC_NODE_2_PORT=1002
ANY_SYNC_NODE_2_QUIC_PORT=1012
ANY_SYNC_NODE_3_PORT=1003
ANY_SYNC_NODE_3_QUIC_PORT=1013
ANY_SYNC_COORDINATOR_PORT=1004
ANY_SYNC_COORDINATOR_QUIC_PORT=1014
ANY_SYNC_FILENODE_PORT=1005
ANY_SYNC_FILENODE_QUIC_PORT=1015
ANY_SYNC_CONSENSUSNODE_PORT=1006
ANY_SYNC_CONSENSUSNODE_QUIC_PORT=1016
  • QUIC ports (those ending in _QUIC_PORT) operate over the UDP protocol.
  • Standard ports operate over the TCP protocol.

iptables Configuration Example

To open the necessary ports for both TCP and UDP traffic using iptables, you can use the following commands:

# Open standard TCP ports
iptables -A INPUT -p tcp --dport 1001 -j ACCEPT
iptables -A INPUT -p tcp --dport 1002 -j ACCEPT
iptables -A INPUT -p tcp --dport 1003 -j ACCEPT
iptables -A INPUT -p tcp --dport 1004 -j ACCEPT
iptables -A INPUT -p tcp --dport 1005 -j ACCEPT
iptables -A INPUT -p tcp --dport 1006 -j ACCEPT

# Open QUIC UDP ports
iptables -A INPUT -p udp --dport 1011 -j ACCEPT
iptables -A INPUT -p udp --dport 1012 -j ACCEPT
iptables -A INPUT -p udp --dport 1013 -j ACCEPT
iptables -A INPUT -p udp --dport 1014 -j ACCEPT
iptables -A INPUT -p udp --dport 1015 -j ACCEPT
iptables -A INPUT -p udp --dport 1016 -j ACCEPT

Make sure to adjust the port numbers as necessary according to your actual configuration.
After running the commands, you can verify the new iptables rules by using:

iptables -L