GEDCOM Import/Export 504 Error on Synology NAS
Posted: Sun Apr 05, 2020 8:27 am
Synology uses an NGINX server configuration. However web station can be configured to use either NGINX or Apache. TNG runs fine with NGINX but If you use Apache, you may get a 504 Gateway Timeout error when processing large GEDCOM files. Fortunately even though the error occurs, TNG continues processing the file until completion, but you cannot see the status. The only way to know when it completes, is to click the page and see if it changes. There are many reasons for 504 errors and some can be disconnects between NGINX, Apache and php execution time limits. Synology suggested changing the php max_execution_time to a higher value, but this has not resolved the problem.
I have not found a way to fix the 504 error but I've found two methods to avoid it. The first method is change the backend to NGINX during the import. If you have a stand alone TNG installation and don't have redirects or something using Apache, it works fine. If you are using WordPress with TNG, it causes a problem because WordPress uses Apache for rewrites. When using NGINX, WordPress will not find any posts or pages. You can add code to NGINX so WordPress functions, but any redirects or other Apache functions will be lost. I'm not sure why, but flipping the backend back and forth seems to cause issues once in a while that requires rebooting the NAS.
The second method, which I use, does not cause problems and seems to be more reliable even when using WordPress. It involves using a virtual host for the internet website and a second TNG installation with local access only. Note if you use a CMS with TNG, it should be installed in a sub-folder, not the web folder. If you run any program in the web folder, which is the "root" for a Synology NAS, visitors may be able to access folders that you intended to be private.
Web Station's General Settings default should be configured for NGINX. Then the virtual host can be configured for the internet version of TNG, WordPress, Joomla etc. using Apache. However you should never have two programs accessing the same database at the same time. If you put the public version of TNG in maintenance mode, you can use a local version to import or export a GEDCOM.
While Darrin doesn't require a second license for running a local version, I'm sure he would appreciate a contribution for all his hard work. He doesn't charge much for the software to begin with, and it's a lot of work keeping everything up to date.
To create the second installation, use DSM and create another TNG folder inside the web folder. You can name this folder whatever you like but I prefer something simple and easy to remember like tngimport. Copy the TNG ZIP file to the new folder and extract the files using DSM File Station. This will set TNG permissions correctly.
Instead of running the TNG setup readme.html file, copy the config.php file from your existing TNG installation to the new tngimport folder. Go to the tngimport folder and open the config.php with an editor that does not use BOM (Byte Order Mark) formatting like Komodo IDE or Notepad++. Alternately you can download and use the Synology text editor available in the package center. Scroll down to the $rootpath about line 54. The line will look something like:
Change this line to point to the new tngimport folder:
To add the local URL address you need to know your server local IP address. If you do not know the address, log in to DSM and go to control panel then select Network and Network Interface.
Click on the active LAN and you will see the address:
Go back to config.php file and scroll down to the $tngdomain variable about line 58.
Change this line to the local address where xxx is your local NAS IP address and the new tngimport folder:
Before you import a file, your TNG public website MUST BE IN MAINTENANCE MODE. Once you've confirmed it is in the maintenance mode, open a new browser window and enter the local URL address for tngimport:
Log in using your normal information and go to the admin page. For safety, configure this install to Require Login and set Allow new user registrations to NO as you should be the only one accessing the local version. Remember this version uses the same database as the internet version so all users and passwords are the same. If someone else has access to this local version, set it in the maintenance mode as well.
Go to the admin section and set up import preferences such as the Default Replace Option, Change Date, living etc. Then import or export the GEDCOM normally. If you performed an import, don't forget to select the Secondary Processes tab and then Select Track Lines. This will add the plus sign back to families with children. When the import is complete turn off the maintenance mode, if it was enabled, log out and close the browser tab. Return to the TNG internet public version and turn maintenance mode off.
I have not found a way to fix the 504 error but I've found two methods to avoid it. The first method is change the backend to NGINX during the import. If you have a stand alone TNG installation and don't have redirects or something using Apache, it works fine. If you are using WordPress with TNG, it causes a problem because WordPress uses Apache for rewrites. When using NGINX, WordPress will not find any posts or pages. You can add code to NGINX so WordPress functions, but any redirects or other Apache functions will be lost. I'm not sure why, but flipping the backend back and forth seems to cause issues once in a while that requires rebooting the NAS.
The second method, which I use, does not cause problems and seems to be more reliable even when using WordPress. It involves using a virtual host for the internet website and a second TNG installation with local access only. Note if you use a CMS with TNG, it should be installed in a sub-folder, not the web folder. If you run any program in the web folder, which is the "root" for a Synology NAS, visitors may be able to access folders that you intended to be private.
Web Station's General Settings default should be configured for NGINX. Then the virtual host can be configured for the internet version of TNG, WordPress, Joomla etc. using Apache. However you should never have two programs accessing the same database at the same time. If you put the public version of TNG in maintenance mode, you can use a local version to import or export a GEDCOM.
While Darrin doesn't require a second license for running a local version, I'm sure he would appreciate a contribution for all his hard work. He doesn't charge much for the software to begin with, and it's a lot of work keeping everything up to date.
To create the second installation, use DSM and create another TNG folder inside the web folder. You can name this folder whatever you like but I prefer something simple and easy to remember like tngimport. Copy the TNG ZIP file to the new folder and extract the files using DSM File Station. This will set TNG permissions correctly.
Instead of running the TNG setup readme.html file, copy the config.php file from your existing TNG installation to the new tngimport folder. Go to the tngimport folder and open the config.php with an editor that does not use BOM (Byte Order Mark) formatting like Komodo IDE or Notepad++. Alternately you can download and use the Synology text editor available in the package center. Scroll down to the $rootpath about line 54. The line will look something like:
Code: Select all
$rootpath = "/volume1/web/genealogy/";
Code: Select all
$rootpath = "/volume1/web/tngimport/";
Click on the active LAN and you will see the address:
Go back to config.php file and scroll down to the $tngdomain variable about line 58.
Code: Select all
$tngdomain = "http://mydomain.com";
Code: Select all
$tngdomain = "http://192.168.1.xxx/tngimport";
Code: Select all
192.168.1.xxx/tngimport
Go to the admin section and set up import preferences such as the Default Replace Option, Change Date, living etc. Then import or export the GEDCOM normally. If you performed an import, don't forget to select the Secondary Processes tab and then Select Track Lines. This will add the plus sign back to families with children. When the import is complete turn off the maintenance mode, if it was enabled, log out and close the browser tab. Return to the TNG internet public version and turn maintenance mode off.