Remote Desktop: Difference between revisions
m tiny fix of syntax in nginx reverse proxy config |
Dangerflask (talk | contribs) Add suggestion for x11vnc instead of TigerVNC as remote/server |
||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 10: | Line 10: | ||
== Self hosting == | == Self hosting == | ||
* [[RustDesk]] | * [[RustDesk]] available in nixpkgs as rustdesk-server | ||
== Clients == | == Clients == | ||
| Line 44: | Line 44: | ||
<code>pathToScript</code> can also be a path to an executable like <code>${pkgs.icewm}/bin/icewm</code> | <code>pathToScript</code> can also be a path to an executable like <code>${pkgs.icewm}/bin/icewm</code> | ||
=== | === TigerVNC === | ||
Nixpkgs has a package but no service. | Nixpkgs has a package but no service. | ||
The server component can be started using the <code>vncserver</code> command. | The server component can be started using the <code>vncserver</code> command. | ||
To connect, use the <code>vncviewer</code> command. | To connect, use the <code>vncviewer</code> command. | ||
For an automated nixos config see [[TigerVNC]]. | |||
However, you'll more likely have success running [https://search.nixos.org/packages?channel=unstable&query=x11vnc&show=x11vnc x11vnc] on the remote/far-away server, while only using `vncviewer` from the TigerVNC package from where you're sitting. Quality documentation for x11vnc usage is at its [https://github.com/LibVNC/x11vnc/?tab=readme-ov-file#readme official repository]. | |||
=== x2go === | === x2go === | ||
| Line 64: | Line 68: | ||
A basic server setup service entry would look like this: | A basic server setup service entry would look like this: | ||
<syntaxhighlight lang="nix"> | |||
services.guacamole-server = { | |||
enable = true; | |||
host = "127.0.0.1"; | |||
port = 4822; | |||
userMappingXml = ./user-mapping.xml; | |||
}; | |||
</syntaxhighlight> | |||
This creates the <code>guacamole-server.service</code> systemd unit. | This creates the <code>guacamole-server.service</code> systemd unit. | ||
| Line 114: | Line 122: | ||
A basic client setup service entry would look like this: | A basic client setup service entry would look like this: | ||
<syntaxhighlight lang="nix"> | |||
services.guacamole-client = { | |||
enable = true; | |||
enableWebserver = true; | |||
settings = { | |||
guacd-port = 4822; | |||
guacd-hostname = "localhost"; | |||
}; | }; | ||
}; | |||
</syntaxhighlight> | |||
This creates a <code>tomcat.service</code> systemd unit. | This creates a <code>tomcat.service</code> systemd unit. | ||
| Line 139: | Line 149: | ||
This example has a virtual host available as <code>https://remote.mydomain.net</code>. It uses the [https://search.nixos.org/options?type=packages&query=services.nginx nginx] service, and [https://letsencrypt.org/ LetsEncrypt] for SSL. Configuration of a DNS domain and records is outside the scope of this document. | This example has a virtual host available as <code>https://remote.mydomain.net</code>. It uses the [https://search.nixos.org/options?type=packages&query=services.nginx nginx] service, and [https://letsencrypt.org/ LetsEncrypt] for SSL. Configuration of a DNS domain and records is outside the scope of this document. | ||
<syntaxhighlight lang="nix"> | |||
services.nginx = { | |||
enable = true; | |||
upstreams."guacamole_server" = { | |||
extraConfig = '' | |||
keepalive 4; | |||
''; | |||
servers = { | |||
"127.0.0.1:8080" = { }; | |||
}; | |||
}; | |||
virtualHosts."remote.mydomain.net" = { | |||
forceSSL = true; # redirect http to https | |||
enableACME = true; | |||
locations."/" = { | |||
extraConfig = '' | |||
proxy_buffering off; | |||
proxy_set_header Upgrade $http_upgrade; | |||
proxy_set_header Connection $http_connection; | |||
proxy_set_header X-Real-IP $remote_addr; | |||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||
proxy_set_header Host $host; | |||
proxy_set_header X-NginX-Proxy true; | |||
proxy_pass http://guacamole_server/guacamole$request_uri; | |||
proxy_redirect http://guacamole_server/ https://$server_name/; | |||
''; | |||
}; | |||
# this sets up the letsencrypt service to get ssl certs for the above | |||
security.acme = { | |||
acceptTerms = true; | |||
defaults.email = "your.email@server.name"; | |||
}; | |||
</syntaxhighlight> | |||
The <code>upstreams."guacamole_server".servers</code> setting points the to IP:port where the <code>guacamole-client</code> webportal is hosted. In this example <code>nginx</code> and <code>guacamole</code> are on the same host. | The <code>upstreams."guacamole_server".servers</code> setting points the to IP:port where the <code>guacamole-client</code> webportal is hosted. In this example <code>nginx</code> and <code>guacamole</code> are on the same host. | ||
| Line 187: | Line 199: | ||
In the case of the above reverse proxy example, the correct firewall ports will also need to be opened on the server hosting the <code>nginx</code> proxy. | In the case of the above reverse proxy example, the correct firewall ports will also need to be opened on the server hosting the <code>nginx</code> proxy. | ||
<syntaxhighlight lang="nix"> | |||
networking.firewall = { | |||
enable = true; | |||
allowedTCPPorts = [ | |||
80 # http | |||
443 # https | |||
8080 # guacamole | |||
4822 # guacamole | |||
]; | |||
}; | |||
</syntaxhighlight> | |||
For any systems that will be reached from the guacamole service, the corresponding ports will need to be opened. The below example opens ports that match the connection settings in the above <code>user-mapping.xml</code>. | For any systems that will be reached from the guacamole service, the corresponding ports will need to be opened. The below example opens ports that match the connection settings in the above <code>user-mapping.xml</code>. | ||
<syntaxhighlight lang="nix"> | |||
networking.firewall = { | |||
enable = true; | |||
allowedTCPPorts = [ | |||
3389 # rdp | |||
]; | |||
}; | |||
</syntaxhighlight> | |||
==== References ==== | ==== References ==== | ||
| Line 222: | Line 236: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
services.xserver | services.xserver = { | ||
enable = true; | |||
displayManager.sddm.enable = true; | |||
desktopManager.plasma5.enable = true; | |||
}; | |||
services.xrdp | services.xrdp = { | ||
enable = true; | |||
defaultWindowManager = "startplasma-x11"; | |||
openFirewall = true; | |||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 254: | Line 272: | ||
To fix this we need to enable and start the systemd unit at boot using <code>wantedBy = [ "graphical.target" ];</code> as shown below: | To fix this we need to enable and start the systemd unit at boot using <code>wantedBy = [ "graphical.target" ];</code> as shown below: | ||
<syntaxhighlight lang="nix">services.gnome.gnome-remote-desktop.enable = true; | <syntaxhighlight lang="nix">services.gnome.gnome-remote-desktop.enable = true; | ||
systemd.services.gnome-remote-desktop = { | systemd.services.gnome-remote-desktop = { | ||
wantedBy = [ "graphical.target" ]; # for starting the unit automatically at boot | wantedBy = [ "graphical.target" ]; # for starting the unit automatically at boot | ||
}; | }; | ||
services.displayManager.autoLogin.enable = false; | services.displayManager.autoLogin.enable = false; | ||
networking.firewall.allowedTCPPorts = [ 3389 ];</syntaxhighlight> | networking.firewall.allowedTCPPorts = [ 3389 ];</syntaxhighlight> | ||
| Line 268: | Line 285: | ||
<code>services.meshcentral.enable = true;</code> | <code>services.meshcentral.enable = true;</code> | ||
[[Category:Applications]] | [[Category:Applications]] | ||
[[Category:Desktop]] | [[Category:Desktop]] | ||
[[Category:Server]] | [[Category:Server]] | ||