How to use HTTP connections in v. 8 or later
Since v. 8, the NoMachine web server, nxhtd, is configured to use only HTTPS connections, by default on port 4443 and doesn't accept any longer HTTP requests (port 4080).
Even if this is the advisable configuration in almost cases, administrators may wish to connect NoMachine web sessions by HTTP, with the automatic redirection to HTTPS.
This requires to edit the configuration file of the web server, web.cfg file:
on Linux /usr/NX/etc/web.cfg
on macOS /Applications/NoMachine.app/Contents/Frameworks/etc/web.cfg
on Windows C:\Program files (x86)\NoMachine\etc\web.cfg
On Linux and macOS
Step 1 - Stop nxhtd.
Run from command line in a terminal:
sudo /etc/NX/nxserver --stop nxhtd
Step 2 - Edit the web.cfg file and look for the following line:
Listen 0.0.0.0:4443 https
Add the listen directive for port 4080 (for HTTP requests):
Listen 0.0.0.0:4080
Listen 0.0.0.0:4443 https
Then add the following section to automatically redirect connection from HTTP to HTTPS:
RewriteEngine On
ReWriteCond %{SERVER_PORT} !^4443$
RewriteCond %{REQUEST_URI} !^/?favicon.ico$
RewriteRule ^/(.*) https://%{SERVER_ADDR}:4443 [R,L]
Step 3 - Start nxhtd
sudo /etc/NX/nxserver --start nxhtd
On Windows
Step 1 - Stop nxhtd.
Execute in a CMD console run as administrator:
%ALLUSERSPROFILE%\NoMachine\nxserver\nxserver.exe --stop nxhtd
Step 2 - Edit the web.cfg file and look for the following line:
Listen 0.0.0.0:4443 https
Add the listen directive for port 4080 (for HTTP requests):
Listen 0.0.0.0:4080
Listen 0.0.0.0:4443 https
Then add the following section to automatically redirect connection from HTTP to HTTPS:
RewriteEngine On
ReWriteCond %{SERVER_PORT} !^4443$
RewriteCond %{REQUEST_URI} !^/?favicon.ico$
RewriteRule ^/(.*) https://%{SERVER_ADDR}:4443 [R,L]
Step 3 - Start nxhtd
%ALLUSERSPROFILE%\NoMachine\nxserver\nxserver.exe --start nxhtd
How to configure web.cfg to use only connections by HTTP (not recommended)
Step 1 - Stop nxhtd.
Step 2 - Add the Listen directive for port 4080 and comment out the directive for HTTPS in web.cfg:
Listen 0.0.0.0:4080
#Listen 0.0.0.0:4443 https
Step 3 - Comment out the redirect directive and add whitelist of URL's for HTTP. These lines, after commenting them, should look like the following.
On Linux and macOS:
#RewriteEngine On
#ReWriteCond %{SERVER_PORT} !^4443$
#RewriteCond %{REQUEST_URI} !^/?favicon.ico$
#RewriteRule ^/(.*) https://%{SERVER_ADDR}:4443/nxwebplayer [R,L]
<VirtualHost _default_:*>
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} !^/?$
RewriteRule ^(.*)$ - [F,L]
</VirtualHost>
On Windows:
#RewriteEngine On
#ReWriteCond %{SERVER_PORT} !^4443$
#RewriteCond %{REQUEST_URI} !^/?favicon.ico$
#RewriteRule ^/(.*) https://%{SERVER_ADDR}:4443/nxwebplayer [R,L]
<VirtualHost _default_:*>
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} !^/?$
RewriteRule ^(.*)$ - [F,L]
PassEnv ALLUSERSPROFILE USERPROFILE
</VirtualHost>
Step 4 - Start nxhtd
