-
Notifications
You must be signed in to change notification settings - Fork 21
Sample setup 3
The default settings will serve Pluto on http://12.34.56.78:8080/
: with http
(not https
), at the IP address (not a domain like example.com
), on port 8080 (not 80 or 443).
This Part 3 explains how to get https, domain and port 80. But you don't always need this! If http://12.34.56.78:8080/
works for your application, then you are done, and the proud owner of a new PlutoSliderServer! Following Part 3 might add unnecessary complexity.
The main reason why these steps can be useful is to get https. This is necessary when:
- Using camera, microphone or GPS inputs in your notebook (e.g.
PlutoUI.WebcamInput
). - You have an advanced setup: a static PlutoSliderServer that deploys to Netlify/GHPages, combined with a dynamic PlutoSliderServer that only does the bonds, and they are linked together. Your static site is only allowed to make requests to the dynamic server if both are on
https
(this is CORS).
The easiest way to get https
is with cloudflare, and you can only get cloudflare if you have a domain, and a server on port 80.
Note
If you use a server managed by your university/company, ask your system administrator how to achieve these steps. You can probably get a domain like https://myproject.mit.edu/
.
You need to buy a domain name (like mycoolwebsite.org
). The easiest place to buy a domain name is njal.la, but most registrars will work (namecheap.com works).
On the website of your registrar (where you bought the domain), go to the DNS settings. Set an "A record" that points from my-pluto-subdomain
to your IP address.
You can now access your PlutoSliderServer at http://my-pluto-subdomain.mydomain.org:8080/
. Nice!
Tip
In step 3 we set up https with cloudflare. If this is what you want, then you could set this up directly. That means that you don't set the A record on your registrar site, but you tell your registrar to use Cloudflare DNS, and you set the A record in cloudflare.
We don't want everyone to add :8080
to the URL! The default port for http is 80, so we want our website to be available at port 80.
The tricky thing is: we don't want to run PlutoSliderServer directly on port 80, because this requires sudo
privileges for running julia
. We want to avoid this because we don't want julia
to read/write files as root
(this would mess up your git directory).
The solution is to run PlutoSliderServer on port 8080, and use a separate server (running as root) to redirect traffic from port 80 to port 8080. We use nginx
for that!
sudo apt install nginx
nginx is now installed and it is configured to run at startup.
Let's configure nginx as a redirect from port 80 to port 8080.
TEMPFILE=$(mktemp)
cat > $TEMPFILE << __EOF__
server {
listen 80 default_server;
listen [::]:80 default_server;
location / {
proxy_pass http://localhost:8080;
}
}
__EOF__
sudo mv $TEMPFILE /etc/nginx/sites-available/default
After changing configuration, restart nginx:
sudo systemctl restart nginx
The easiest way to get https is to use cloudflare. Register an account, set up your domain to use their DNS (check the cloudflare docs), make sure the A record is there, and enable the "Always HTTPS" service. (Cloudflare is also very useful for caching! This will make your PlutoSliderServer faster.)
Alternatively, you can set up HTTPS yourself with nginx
and Let's Encrypt, but this is beyond the scope of this tutorial. 💛
Now, your service should be available at https://my-pluto-subdomain.yourdomain.org/
. Nice!