Remote Desktop: Difference between revisions
mNo edit summary |
Fix syntax highlighting |
||
| (5 intermediate revisions by 3 users not shown) | |||
| Line 10: | Line 10: | ||
== Self hosting == | == Self hosting == | ||
* [[RustDesk]] | * [[RustDesk]] available in nixpkgs as rustdesk-server | ||
== Clients == | == Clients == | ||
| Line 64: | Line 64: | ||
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 118: | ||
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 145: | ||
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 195: | ||
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 232: | ||
<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 268: | ||
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 | 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 281: | ||
<code>services.meshcentral.enable = true;</code> | <code>services.meshcentral.enable = true;</code> | ||
[[Category:Applications]] | [[Category:Applications]] | ||
[[Category:Desktop]] | [[Category:Desktop]] | ||
[[Category:Server]] | [[Category:Server]] | ||