Page tree
Skip to end of metadata
Go to start of metadata

Original source by WilliamDraco.

This document provides instructions to setup nwsync from the beginning, including an http server. This is aimed at a windows user who needs only basic features, but most instructions are platform agnostic.

Disclaimer: I am not affiliated with Beamdog and have written these instructions based on my own experiences. While I have tried to cover a few corner cases where I can, it’s not even the same field as my day job so problems may still occur.

1. Set up a http server

The best http server method is to pay a service for proper webhosting. The service needs to provide public-facing http access to download files. Clients make many connections/requests during transfer, and so services which charge per-connection/per-http request should be avoided. If you have such an option, skip to step 2.

Intro

This is the setup of a no-cost option for nwserver hosts to create a ‘self-serve’ nwsync host. This self-serve option is restricted by the nwsync host’s upload speeds or limits, and will be subject to any ISP restrictions that the nwsync host has i.e. many residential service contracts ban file hosting. Note that the nwserver host and the nwsync host do not need to be the same computer/network/continent.

http vs https - As of v1.79 (8193.0), both are supported. The below establishes an http-only server which is sufficient in practice for nwsync. Should https become a requirement this guide will be extended to enable https.

Instructions

Port Forwarding

Enable port forwarding of inbound traffic over port 80 towards the nwsync host. This is an option on most internet routers, but each router software is different. If you don’t know how to port forward for your particular brand/model, google search something like Port Forwarding *router name*

Nginx

http://nginx.org/en/download.html

Nginx is a popular, trusted webserver and the setup is very easy for the most basic of servers that we need.

    For Windows

  1. Download the appropriate version, extract it directly to an application directory. There is no install process for Nginx.
    1. Open this directory and find nginx.exe. In that same directory Right-Click-> New -> Text Document. Name it "nginx.txt". Open the text file and put the following:

start nginx.exe

cmd /k

    1. Save and close the file. Then, rename the file nginx.bat. Windows will warn you about changing extensions - accept it.
    2. You should now have both nginx.exe and nginx.bat next to each other.
  1. Run nginx.bat from inside that directory. A cmd window will open.
  2. Open your web browser of choice and type the host's public IP address into the search bar. For example, http://172.217.167.100 (this is the IP of Google Search). You can find the public IP by navigating to https://www.whatismyip.com/ from the host computer.
  3. If this presents the "Welcome to nginx" page, Everything is working thus-far. If not check the following:
    1. Confirm your port-forwarding options and check any firewalls which might be blocking connections.
    2. It’s also wise to test using an ‘outside' connection - Either get a friend to attempt it from home or use a mobile phone on data (not Wi-Fi).
  4. In the cmd window opened at step 2, type nginx -s quit . This will gracefully shut down nginx.
  5. There is no feedback that Nginx is closed. On windows use the following command in the same cmd window - it should show ‘no matching tasks’ if the shutdown was successful
    tasklist /fi "imagename eq nginx.exe”


    For Linux

    While I do not have personal experience with Linux, here is a simple installation steps I’ve found to    install nginx (based on ubuntu):

  1. Installation is as simple as:
    sudo apt update

sudo apt install nginx

  1. To start nginx:
    sudo systemctl start nginx 
  2. To stop nginx:
    sudo systemctl stop nginx
  3. Testing the current operations is the same as steps 3-4 for windows above.


    Note this installs the nginx as a service, which should start automatically at boot. This behavior can be     controlled using the systemctl keywords “enable” and “disable”. You can always check the current    status using:
    sudo systemctl status nginx

Nginx has a large feature set as a webserver, but most of those options are unnecessary for this simple purpose and can be ignored.

2. Preparing nwsync


  1. Download nwsync https://github.com/Beamdog/nwsync/releases . Extract and place all components into a folder (Note: the latest version, v0.3.2, does not include a required .dll file which will give an unrecognisable error later. The newer .exe is preferable, but please also download and extract the .dll files from an earlier version, and place them inside this same folder)
    1. While not a strict nwsync requirement, for basic use nwsync should be installed on a computer that can run the nwn module via nwserver (even if not the one that does run the module), because it will auto-locate the needed hak/tlk files the same way that nwserver does. This will look something like:
      1. Module in documents/nwn/module
      2. Haks in documents/nwn/hak
      3. Tlk in documents/nwn/tlk
    2. Many people find that nwsync takes exceptionally long (days) when prepared on low-resource hardware (such as a low-power laptop or a small Virtual Machine). My guess is related to limited RAM, or slow hard drives choking the process. Suggest you prepare nwsync on a well-provisioned computer (and then transfer/move the prepared data to your hosting solution, as applicable)
  2. Download my unofficial gui wrapper https://github.com/WilliamDraco/nwsync_gui/releases . This prepares and runs the command line options for nwsync for you. Place the nwsync_gui.exe into the same directory as nwsync (or it can find nwsync via PATH, if you know what that is)
    1. If you are familiar/comfortable with the nwsync command lines, skip the gui and run the commands directly. Then, proceed to step 3. Running nwserver
  3. Run nwsync_gui.exe
  4. Choose a Source - Select your modulename.mod file
    1. All sorts of package files (mod, erf, hak) can be nwsync’d to meet different needs, but for the basic case just select mod.
    2. If you want to include Portraits, Music or Ambient Sounds in your nwsync, pack them within a hak file and include it in the module - This is due to a limitation in nwsync_gui that is planned to be resolved in the future.
  5. Choose a Destination folder
    1. If you complete the ‘Set up a http server’ step above you should select the 'html' folder inside the nginx directory and then create a subfolder such as 'nwsyncdata'. The remainder of the walkthrough will assume you did this.
    2. If you are using a paid/hosted http solution, this is a temporary destination until you can upload to your host. How you upload to your host will depend on the host itself.
  6. Click the large "RUN NWSYNC WRITE" button and wait for it to finish. This can take a while - Let it run.


3. Running nwserver to serve nwsync content

Nwserver command-line option

On windows, the user interface for nwserver does not have an option to enable nwsync. Therefore, nwserver must be launched with command-line options to use nwsync. Linux has only ever had the console/terminal option.

See http://neverwinternights.info/dedicatedserver.htm for information on the Command-Line options, and how to use them on windows if unfamiliar.

nwsync adds a new command-line option in addition to the above:

     -nwsyncurl http://your.ip.addr.ess/subfolder

your.ip.addr.ess 

  • Self-hosted: This is the public IP address that you got during the 'set up a http server' step 3
  • Paid-hosting: The address you use to access your webhost content by browser, which is likely via a domain name like ‘www.paidhosting.com

/subfolder

  • The name of the subfolder set-up during the 'Preparing nwsync' step 5. If you did not create a subfolder, simply exclude /subfolder
  • Following the examples above the complete command would be

     -nwsyncurl http://172.217.167.100/nwsyncdata

Running nwserver

  1. Always ensure the webhost (nginx) is running/available prior to starting nwserver.
  2. Run nwserver including the new command-line option per the above.


Note that, per the nwsync instructions, at present nwserver continues to use content files (hak/tlk/etc) the same way as it used to. Therefore your server must still have access to a copy of those files in order to run correctly. Nwserver cannot read nwsync data - it merely tells the client where they can find the data for themselves.

4.What if I have a dynamic IP (Self-hosting)?

If you’ve chosen to self-host and the nwsync-host has a connection which uses a dynamic IP, the -nwsyncurl command would have to change frequently in order to match the IP as it moved around. This is a tedious process to follow. While a static IP would be preferable, a dynamic IP can be mitigated using a DNS service.

Any dns service is fine, and if you want to purchase your own domain name and manage the DNS to resolve to your dynamic IP you are welcome to do so, however a free option for this walkthrough is to use www.duckdns.org:

  1. Follow the above link and register using any of the available options.
  2. Once logged-in, under the 'Domains' header you'll see an option to create a domain with a custom name. Enter your choice of name (Players don’t need to know it/remember it, so it is okay to be complicated, difficult to read or long) and click the green "add domain" button. e.g. http://modulename.duckdns.org
  3. Your domain will appear in the list and should autofill with your current IP address if available. Now, instead of using your public IP in the -nwsyncurl, instead use this domain name. Example:

    -nwsyncurl http://modulename.duckdns.org/nwsyncdata

  1. Back on the duckdns website, go to the ‘install’ header found near the top of the page.
  2. Follow the instructions provided to select your operating system and implement a script/program that will auto-update the duckdns entry every 5 minutes in order to adjust when the dynamic IP address changes. For beginners on windows, the 'Windows - GUI' option is recommended.
  3. Ensure the script/program is active/running prior to launching nwserver


5. Updating nwsync content

When the time comes to update the content being served to players, do the following:

  1. Update the custom content the same way as previously (Add/remove content from haks, or add/remove haks from module) and save.
  2. Run nwsync_gui.exe (it should remember your previous selections - if not, reselect source/destination)
  3. Click "RUN NWSYNC WRITE" button and wait - It will be significantly faster than the first time but may still take a while as it checks for differences and updates as required.
  4. Restart nwserver (noting that it does not have to be offline while the new nwsync data is being written written)
    1. Remember to update your nwserver .hak/.tlk files, as nwserver cannot currently read from nwsync.


Other nwsync functions

Prune

This nwsync sub-program operates on a repository (folder containing nwsync data) and checks the data for a number of simple errors, alongside deleting data no longer in use.

If you consider the nwsync repository like a filing cabinet - Each time you “write” the program:

  • Considers the list of documents you gave it (the source)
  • Checks the filing cabinet for whether each of the documents exists (Note a different ‘version’ of a document is considered a ‘different document’)
  • If the document doesn’t exist, it adds it to the filing cabinet
  • Once done, it uses the source list as an index of the cabinet, so it knows which draw/section of the filing cabinet a document is in.


Note that in the above analogy, at no point does nwsync remove any contents from the filing cabinet. But what happens if you remove a document from your source list? Will it stay in the cabinet forever?

Yes, the repository/filing cabinet will keep every copy of a file ever put into it - Unless you prune it. Pruning is simply the process whereby nwsync checks the contents of the cabinet against the current index (or indexes, as you can have multiple manifests in one repository) of the cabinet. Where a document is no longer on any index, that document gets thrown away.

This is primarily useful to remove the wasted storage space for unused documents. Note: It may provide a minimal speed increase, but should not be considered “the point”.

Print

Lastly, this nwsync sub-program outputs the checksum reference and filename of each document within a specific manifest (not repository). To stick with the above analogy - This prints out the index file in a human-readable format.

I’m… not quite sure what the use case is for this but there you go.

  • No labels