If the configuration is correct, your OPNSense back-end pool will be responding to incoming requests based on a round robin principle with a sticky cookie, so that your device stays connected to the single web server. How can you know which host you have reached?
- Here is how you can set up
X-Served-Byheader in nginx:
nano /etc/nginx/nginx.conf
# Find the http section and add it somewhere in there:
http {
# Include web VM hostname (added for debugging)
add_header X-Served-By $hostname;
..
}
- Access one of your self-hosted websites and identify the header.
- Activate the developer tools (
F12on Windows/Linux orOption + ⌘ + Jon a Mac) - Go to Network → find the first item in the list → Headers
- Scroll down in the headers to find the ‘X-Served-By’ header.
- Activate the developer tools (
- Try opening another incognito window to reach the other host. Now try uploading content on one host and see if it displays on the other. This could be an attachment, for example. Does it appear on the other host?
- If you cannot reach the other host this way after you have uploaded content to one, you can simply remove the host from the back-end pool to force the other one to be used.
When can this be useful?
- A visitor reports that content loads differently from their end and you want to confirm which web server they are hitting.
- Sync issues – you upload a file and it vanishes upon page refresh – you can check which VM you were on during upload and after refreshing the page – if they differ, this could point to Syncthing not working or not distributing the content fast enough.
Once completed, then I can but congratualte you! You have a working async replication of data between web server nodes that works both on the same site as well as in between sites. Just in case you had some doubts about whether Syncthing is the tool for you, feel free to check out the next Step to see some alternatives, their pros and cons.
