Enable remote access

By default, a workstation install is private to the computer it runs on. This page is for when you want other people to reach the website over a network, and it walks you through doing that safely.

A cluster install already listens on the network with login on, and so does a workstation install that answered n to Will people use nextPYP only from this computer? (or passed PYP_REMOTE=true). Check with nextpyp config get web.host: if it prints 0.0.0.0, you’re already set and can skip this page.

Otherwise pick the one of the three cases below that matches your network. Run the commands with sudo on an administrator install, or as ./nextpyp from the install folder on a regular-account install.

Private network

Choose this option if your server is not reachable from the internet, and you want to open the website from other computers on the same private network.

Warning

If you follow these instructions, but your server is reachable from the public internet, this configuration will leave your system in an insecure state and at higher risk of a security compromise! Only choose this option if you’re sure the server is not reachable from outside of your trusted private network.

First, tell the website to listen on every network interface:

sudo nextpyp config set web.host 0.0.0.0
sudo nextpyp restart

Next, make sure login is on. A website on the network without login lets anyone on that network use it. Check with nextpyp config get web.auth; it must print login. If it prints none, turn login on as described on Installer settings.

If the machine runs a firewall, open port 8080 so other computers can get in:

sudo ufw allow 8080/tcp
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload

When ./install is given PYP_REMOTE=true, it opens port 8080 itself (firewalld when that is active, otherwise ufw). Changing web.host afterwards does not re-run that step.

Note

Cloud security groups and a site firewall are separate from the machine’s own firewall. If the page won’t load from another computer even after the commands above, check those too.

Then open http://hostname:8080 in your web browser, where hostname is the network name of the server. The raw IP address works too, e.g. http://10.0.0.5:8080. If login was just turned on, the first page creates the administrator account.

Public internet with the bundled HTTPS proxy

Choose this option if you want to use the website from an untrusted network, like the public internet.

Warning

A website that anyone on the internet can reach will be probed by strangers. Keep login on and use this HTTPS proxy. Do not expose port 8080 to the public internet instead; that plain-HTTP setup is only for the private-network case above.

Before you start, you’ll need two things:

  • Domain name. The server needs a public domain name, e.g. myserver.myorganization.org. Raw IP addresses do not work. If PYP_DOMAIN does not resolve, or every address it resolves to is private, ./install and nextpyp doctor warn that Caddy cannot obtain a public certificate. Use the private-network option and port 8080 instead.

  • Root access. Installing the reverse proxy requires root on the web server.

If you gave the wizard a public domain name, or passed PYP_DOMAIN on the command line, the installer already did this, so there’s nothing to run. Check with sudo systemctl status nextPYP-rprox below.

To add the proxy to an install that does not have it, run install-rprox from the install folder with the domain name:

cd /opt/nextpyp
sudo PYP_DOMAIN=myserver.myorganization.org ./install-rprox

It is the same as sudo nextpyp rprox myserver.myorganization.org. Nothing is downloaded: the proxy container is part of the installed release, and an upgrade brings its proxy along. sudo nextpyp rprox --remove (or ./current/uninstall-rprox) takes the proxy away again, and ./uninstall removes it with everything else.

Note

The domain name must be resolvable from the public internet. Shortcuts like localhost and raw IP addresses do not work.

The installer created a systemd daemon named nextPYP-rprox. Check it with:

sudo systemctl status nextPYP-rprox

A successful start looks like:

● nextPYP-rprox.service - nextPYP-rprox
     Loaded: loaded (/etc/systemd/system/nextPYP-rprox.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-11-16 21:44:24 UTC; 21s ago
   Main PID: 3101 (starter)
      Tasks: 22 (limit: 4558)
     Memory: 58.1M
        CPU: 221ms
     CGroup: /system.slice/nextPYP-rprox.service
             ├─3101 "Apptainer instance: root [reverse-proxy]"
             ├─3102 appinit "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             └─3125 caddy run --config /var/www/reverse-proxy/Caddyfile

Now visit https://myserver.myorganization.org in your browser. If that fails, see troubleshooting.

Note

Use https and leave off :8080. The proxy answers on the standard HTTPS port, so the address is just the domain name.

When ./install is given PYP_DOMAIN, it opens ports 80 and 443 (port 80 must be reachable for the certificate). Changing the configuration afterwards does not re-open them; open them yourself then.

Note

Cloud security groups and a site firewall are separate from the machine’s own firewall. If the certificate can’t be issued or the page won’t load, check those too.

Your own proxy with single sign-on

Choose this option if your site already has a reverse proxy that signs people in (single sign-on) and forwards a user header to nextPYP.

Set web.auth to reverse-proxy. The website then trusts web.authHeader (X-userid unless you change it) only from addresses in web.trustedProxies. The default is 127.0.0.1 and ::1, which is a proxy running on this machine:

[web]
auth = 'reverse-proxy'
trustedProxies = [ '127.0.0.1', '::1' ]

While that list is still the default, the installer binds the website to 127.0.0.1. With PYP_AUTH=reverse-proxy, PYP_REMOTE=true is refused until PYP_TRUSTED_PROXIES names the proxy. nextpyp doctor prints WARN: The website answers on 10.1.2.5, which is outside the trusted list. when the site answers on an address that is not in the list. A user header from that address is ignored. Set web.trustedProxies to the proxy address. See Security.

Compute jobs call the website at /pyp. That path uses its own token, not the browser login. The proxy must forward /pyp without an interactive login page. It must also drop any X-userid header the browser sent, and then set the header itself. A client that is allowed to supply the header can choose which account it uses.

Warning

Getting the header handling wrong lets any browser pick its own account, so test with a request that sends its own X-userid before you rely on this setup.

location /pyp {
   proxy_pass http://127.0.0.1:8080;
   proxy_set_header X-userid "";
}

location / {
   proxy_pass http://127.0.0.1:8080;
   proxy_set_header X-userid $remote_user;
}
<Location /pyp>
   ProxyPass http://127.0.0.1:8080/pyp
   RequestHeader unset X-userid
</Location>

<Location />
   ProxyPass http://127.0.0.1:8080/
   RequestHeader set X-userid expr=%{REMOTE_USER}
</Location>
reverse_proxy 127.0.0.1:8080 {
   header_up X-userid ""
}

reverse_proxy 127.0.0.1:8080 {
   header_up X-userid $remote_user
}