# Rock the Lovely Pluto.jl Notebook in the LXD-LXC Cloud behind Nginx

**URL:** https://discourse.julialang.org/t/rock-the-lovely-pluto-jl-notebook-in-the-lxd-lxc-cloud-behind-nginx/107756
**Category:** Tooling
**Tags:** pluto
**Created:** [December 18, 2023, 7:06am UTC](https://discourse.julialang.org/t/rock-the-lovely-pluto-jl-notebook-in-the-lxd-lxc-cloud-behind-nginx/107756 "2023-12-18T07:06:47Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Guanglin\_Du](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/guanglin_du/32/43088_2.png) [@Guanglin\_Du](https://discourse.julialang.org/u/Guanglin_Du)
#### Post date: [December 18, 2023, 7:06am UTC](https://discourse.julialang.org/t/rock-the-lovely-pluto-jl-notebook-in-the-lxd-lxc-cloud-behind-nginx/107756/1 "2023-12-18T07:06:47Z")

</div>

**1. Background**

- A private cloud based on the powerful LXD-LXC system container technology
- Nginx as the frontend to support both HTTP and HTTPS
- Ubuntun or Arch Linux-based containers

**2. Install Julia onto your container and configure your .bashrc or .zshrc**

```julia
lxc file push ~/julia-1.9.4-linux-x86_64.tar.gz u2204-01/home/ubuntu/
lxc exec u2204-01 -- su - ubuntu --login
sudo tar -xzf ./julia-1.9.4-linux-x86_64.tar.gz -C /opt/

```

- vim ~/.zshrc

```julia
export JULIA_HOME="/opt/julia-1.9.4"
export JULIA_PKG_SERVER="https://mirrors.pku.edu.cn/julia"
PATH+=":$JULIA_HOME/bin"

```

- source ~/.zshrc

**3. Install Pluto** (Easy. Omitted.)

**4. Install tmux to manage a Pluto session in the container**

```julia
sudo apt-get install tmux (Ubuntu)
sudo pacman -S tmux (Arch Linux)

```

**5. Create a new tmux session and run Pluto**

- I set both the require\_secret\_for\_open\_links and require\_secret\_for\_access flags to false, Choose what you like.

```julia
tmux new -s mypluto

julia> import Pluto; Pluto.run(;host="0.0.0.0", port=1234, launch_browser=false, require_secret_for_open_links=false, require_secret_for_access=false)
[ Info: Loading...
┌ Info:
└ Go to http://0.0.0.0:1234/ in your browser to start writing ~ have fun!
┌ Info:
│ Press Ctrl+C in this terminal to stop Pluto
└

```

- Exit the tmux session: Ctrl B D
- Re-enter the session: tmux attach-session -t mypluto

**6. Congiure your Nginx - the HTTP way with port 1234**

- /etc/nginx/conf.d/pluto\_http.conf
- URL: http//YOUR\_DOMAIN\_NAME:1234 or http//SERVER\_IP\_ADDRESS:1234

```julia
server {
  listen 1234;
  listen [::]:1234;
  
  server_name 240.5.113.13;

  location / {
    proxy_pass http://240.5.113.13:1234; 
  }
}

```

**7. Configure your Nginx - the preferred HTTPS way with a URL path**

- /etc/nginx/nginx.conf

- URL: http//YOUR\_DOMAIN\_NAME/pluto or http//SERVER\_IP\_ADDRESS/pluto  
…  
(Omitted common settings)   
http {  
ssl\_session\_cache shared:SSL:10m;  
#ssl\_session\_timeout 10m;  
ssl\_session\_timeout 1d;

```julia

```

---

<div class="post-metadata">

### Author: ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)
#### Post date: [December 18, 2023, 9:36am UTC](https://discourse.julialang.org/t/rock-the-lovely-pluto-jl-notebook-in-the-lxd-lxc-cloud-behind-nginx/107756/2 "2023-12-18T09:36:04Z")

</div>

That is a great writeup. Have you tried using the juliaup installer ?

---

<div class="post-metadata">

### Author: ![Guanglin\_Du](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/guanglin_du/32/43088_2.png) [@Guanglin\_Du](https://discourse.julialang.org/u/Guanglin_Du)
#### Post date: [December 18, 2023, 11:52pm UTC](https://discourse.julialang.org/t/rock-the-lovely-pluto-jl-notebook-in-the-lxd-lxc-cloud-behind-nginx/107756/3 "2023-12-18T23:52:04Z")

</div>

Thanks. No. I know nothing about the juliaup installer. Let me have a look at it.

---

<div class="post-metadata">

### Author: ![Guanglin\_Du](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/guanglin_du/32/43088_2.png) [@Guanglin\_Du](https://discourse.julialang.org/u/Guanglin_Du)
#### Post date: [December 19, 2023, 6:26am UTC](https://discourse.julialang.org/t/rock-the-lovely-pluto-jl-notebook-in-the-lxd-lxc-cloud-behind-nginx/107756/4 "2023-12-19T06:26:21Z")

</div>

Nginx is powerful. However, its configuration is not easy and obvious. Sometimes, I feel it’s confusing and frustrating, instead. If the above configuration in **7.** is problematic as I encountered in a newer LXD-LXC 5.x cloud, try the following

```julia
        location /pluto/ { # Note the trailing slash!!!
            proxy_pass http://240.4.186.231:1234/; # Note the trailing slash!!!
            #proxy_buffering off;
            proxy_redirect off;

            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Proto $scheme;

            # WebSocket headers
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header X-Scheme $scheme;
        }

```

---

<div class="post-metadata">

### Author: ![Guanglin\_Du](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/guanglin_du/32/43088_2.png) [@Guanglin\_Du](https://discourse.julialang.org/u/Guanglin_Du)
#### Post date: [December 20, 2023, 1:18am UTC](https://discourse.julialang.org/t/rock-the-lovely-pluto-jl-notebook-in-the-lxd-lxc-cloud-behind-nginx/107756/5 "2023-12-20T01:18:16Z")

</div>

My command to start Pluto ( **auto\_reload\_from\_file=true** ensures that \*.jl files refresh correctly.):

```julia
julia> import Pluto; Pluto.run(;host="0.0.0.0", port=1234, launch_browser=false, require_secret_for_open_links=false, require_secret_for_access=false, auto_reload_from_file=true)
┌ Info:
└ Go to http://0.0.0.0:1234/ in your browser to start writing ~ have fun!
┌ Info:
│ Press Ctrl+C in this terminal to stop Pluto
└

```
