From 0b2dc4fb0c83a5cacc9bbfabb76ab9a8b7d33a01 Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Sun, 3 Mar 2024 09:43:13 +0100 Subject: [PATCH] Add deploy --- assets/css/main.css | 1 + one.org | 46 +++++++++++++++++++++++++++++++++++++++++++++ onerc.el | 2 ++ 3 files changed, 49 insertions(+) diff --git a/assets/css/main.css b/assets/css/main.css index 03d4f93..2b9cf34 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -136,6 +136,7 @@ a:hover, border-bottom: 2px solid var(--color-brown); background-color: var(--color-black); overflow-x: auto; + overflow-y: hidden; } @media (width < 600px) { diff --git a/one.org b/one.org index 032e465..0efb267 100644 --- a/one.org +++ b/one.org @@ -321,6 +321,52 @@ And open the browser at ~http://localhost:8000/~. You should see the home page w #+ATTR_HTML: :class block-center [[#/img/quickstart/minimal-template.webp][Random number]] +* Deploy +:PROPERTIES: +:ONE: one-custom-default-doc +:CUSTOM_ID: /docs/deploy/ +:TITLE: Deploy +:DESCRIPTION: Deploy Django LiveView to production. +:END: + +You can deploy Django LiveView using any web server like reverse proxy. + +** Nginx + + I recommend using Nginx. Here is an example of how to configure. Replace ~example.com~ with your domain and ~my-project~ with your folder name. + +#+BEGIN_SRC nginx +server { + listen 80; + server_name example.com; + + location / { + proxy_pass http://127.0.0.1:8000; + proxy_set_header Host $host; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Host $server_name; + proxy_set_header X-Real-IP $remote_addr; + proxy_redirect off; + } + + location /static { + root /var/www/my-project; + } + + location /media { + root /var/www/my-project; + } + + location = /favicon.ico { access_log off; log_not_found off; } +} +#+END_SRC + +It is important to note that the ~proxy_set_header~ lines are necessary for the WebSocket to work. You can see more about it in [[https://channels.readthedocs.io/en/latest/deploying.html][Channels]]. + * FAQ :PROPERTIES: :ONE: one-custom-default-doc diff --git a/onerc.el b/onerc.el index dd285c9..f7bc485 100644 --- a/onerc.el +++ b/onerc.el @@ -105,6 +105,8 @@ (:ul.nav__list.nav__list--docs.nav-docs__list (:li.nav-docs__item (:a.nav-docs__link (@ :href "/docs/quickstart/") "Quickstart")) + (:li.nav-docs__item + (:a.nav-docs__link (@ :href "/docs/deploy/") "Deploy")) (:li.nav-docs__item (:a.nav-docs__link (@ :href "/docs/faq/") "FAQ")) )))