Knowledge Base
Searching in : Article
ID: AR07S01136
Applies to: NoMachine Technology
Added on: 2021-07-13
Last Update: 2021-07-15

How to configure a web server to associate the .nxs file to the NoMachine client app

This article is for system administrators who need to distribute client session files (.nxs) to their users through for example the Company's web portal.

In some cases browsers display the NoMachine session files (.nxs) as XML or show an empty page instead of downloading them or proposing to execute them by NoMachine client.

This can be solved by configuring the NoMachine web server (nxhtd) to instruct browsers to download the .nxs files, see the following example.

Step 1 - Create the connection file and place it under the Document Root of the NoMachine web server
Execute the following instructions with administrative provileges. On Linux and macOS use the 'root' user or execute the operations with 'sudo'. On Windows, use an administrator account.


1.1. Create a .nxs file, named connect.nxs via NoMachin client UI.

1.2. Create the downloads directory:
Linux "/usr/NX/share/htdocs/downloads"
macOs "/Applications/NoMachine.app/Contents/Frameworks/share/htdocs/downloads"
Windows  "C:/Program Files (x86)/NoMachine/share/htdocs/downloads"

1.3. Store the connect.nxs file in the downloads directory.

1.4. Set proper permissions and ownership (not required on Windows):

on Linux
$ sudo chmod -R 700  /usr/NX/share/htdocs/downloads
$ sudo chown -R nxhtd:nxhtd /usr/NX/share/htdocs/downloads

on macOS
$ sudo chmod -R 700  /Applications/NoMachine.app/Contents/Frameworks/share/htdocs/downloads
$ sudo chown -R nxhtd:nxhtd /Applications/NoMachine.app/Contents/Frameworks/share/htdocs/downloads

 

Step 2 - Modify the htd.cfg file

2.1. To force browsers to download the .nxs file,  add the following lines at the end of the htd.cfg file.

Location of the htd.cfg file:
Linux "/usr/NX/etc/htd.cfg"
macOs "/Applications/NoMachine.app/Contents/Frameworks/etc/htd.cfg"
Windows  "C:/Program Files (x86)/NoMachine/etc/htd.cfg"

Linux:
<Directory "/usr/NX/share/htdocs/downloads">
  <Files *.nxs>
    ForceType application/octet-stream
    Header set Content-Disposition attachment
  </Files>
</Directory>

macOS:
<Directory
"/Applications/NoMachine.app/Contents/Frameworks/share/htdocs/downloads">
  <Files *.nxs>
    ForceType application/octet-stream
    Header set Content-Disposition attachment
  </Files>
</Directory>

Windows:
 <Directory "C:/Program Files (x86)/NoMachine/share/htdocs/downloads">
  <Files *.nxs>
    ForceType application/octet-stream
    Header set Content-Disposition attachment
  </Files>
</Directory>
 

2.2. To allow the browser to access content of .nxs file, add the following RewriteCond line:

    RewriteCond %{REQUEST_URI} !^/?downloads/.*\.nxs$

    to the existing 'Rewrite' section in order to have exactly:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/?nxwebplayer$ [NC]
    RewriteCond %{REQUEST_URI} !^/?(event|eventinit)$
    RewriteCond %{REQUEST_URI} !^/?nxplayer/(js|images|style|languages)/.*$
    RewriteCond %{REQUEST_URI} !^/?nxinfo/[a-fA-F0-9]{32}\.info$
    RewriteCond %{REQUEST_URI} !^/?favicon.ico$
    RewriteCond %{REQUEST_URI} !^/?downloads/.*\.nxs$
    RewriteCond %{REQUEST_URI} !^/?$
    RewriteRule ^(.*)$ - [F,L]
 

IMPORTANT: the new line MUST be placed between: "RewriteEngine On" and "RewriteRule ^(.*)$ - [F,L]"

2.3. Restart nxhtd
You can do this via server UI or from command line.

On Linux and macOS, execute in a terminal:

$ sudo /etc/NX/nxserver --restart nxhtd

On Windows open a CMD console as administrator and execute:

> cd C:\Program files (x86)\NoMachine\bin\
> nxserver --restart nxhtd

Step 3 - Access by browser the .nxs file
To access the connect.nxs file, point your browser to:

http://SERVER_IP:4080/downloads/connect.nxs

For example:
http://192.168.1.2:4080/downloads/connect.nxs
 


Some references
The most frequently asked options for pre-configuring the client and the session behavior
v. 7 https://kb.nomachine.com/DT11R00186

v. 6 https://kb.nomachine.com/DT10O00159