mirror of
https://github.com/etesync/server
synced 2024-11-25 18:28:46 +00:00
Update page to use uvicorn
parent
22d14bc69f
commit
c21d9ca2c4
@ -1,5 +1,5 @@
|
|||||||
This page details how to create a production setup for the Etebase server.
|
This page details how to create a production setup for the Etebase server.
|
||||||
There exist many ways of doing this, but this guide uses `Daphne` as ASGI and `Nginx` as web server.
|
There exist many ways of doing this, but this guide uses `uvicorn` as ASGI and `Nginx` as web server.
|
||||||
|
|
||||||
We do because its not a good idea to just run the basic debug server and expose it to the outside world.
|
We do because its not a good idea to just run the basic debug server and expose it to the outside world.
|
||||||
Instead, a component stack should be built.
|
Instead, a component stack should be built.
|
||||||
@ -8,32 +8,10 @@ In this guide, we will create the following stack:
|
|||||||
> `the web client <-> Nginx <-> the socket <-> Daphne <-> Django`
|
> `the web client <-> Nginx <-> the socket <-> Daphne <-> Django`
|
||||||
|
|
||||||
|
|
||||||
## Daphne
|
## Uvicorn
|
||||||
|
|
||||||
### Installing Daphne
|
If uvicorn is not yet set up, refer to the [basic setup page](https://github.com/etesync/server/wiki/Basic-Setup-Etebase-(EteSync-v2)), where it is explained.
|
||||||
|
|
||||||
Installation of Daphne is easily done via pip.
|
|
||||||
Make sure to install it inside of your virtual environment if you are using one.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ cd path/to/etebase
|
|
||||||
$ source venv/bin/activate # In case you haven't activated the venv yet.
|
|
||||||
$ pip3 install daphne
|
|
||||||
```
|
|
||||||
|
|
||||||
### Testing Daphne
|
|
||||||
|
|
||||||
We can already test whether our daphne installation works.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ cd path/to/etebase
|
|
||||||
$ source venv/bin/activate # In case you haven't activated the venv yet.
|
|
||||||
$ daphne -b 0.0.0.0 -p 8000 etebase_server.asgi:application
|
|
||||||
```
|
|
||||||
|
|
||||||
This command runs the Etebase application and exposes it on port 8000.
|
|
||||||
On the machine itself, you can now surf to `localhost:8000` to check if it works.
|
|
||||||
If you're on a different machine than the one running the server, surf to its local IP address followed by the port number, e.g. `192.168.x.x:8000`.
|
|
||||||
|
|
||||||
## Nginx
|
## Nginx
|
||||||
|
|
||||||
@ -106,14 +84,14 @@ After restarting Nginx and launching Daphne (on port 8001), you should be able t
|
|||||||
$ sudo cp etebase_nginx.conf /etc/nginx/sites-available/
|
$ sudo cp etebase_nginx.conf /etc/nginx/sites-available/
|
||||||
$ sudo ln -s /etc/nginx/sites-available/etebase_nginx.conf /etc/nginx/sites-enabled/etebase_nginx.conf
|
$ sudo ln -s /etc/nginx/sites-available/etebase_nginx.conf /etc/nginx/sites-enabled/etebase_nginx.conf
|
||||||
$ systemctl restart nginx
|
$ systemctl restart nginx
|
||||||
$ daphne -b 0.0.0.0 -p 8001 etebase_server.asgi:application
|
$ uvicorn etebase_server.asgi:application --port 8001 --host 0.0.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
If you encounter any errors, the Nginx log is located in `/var/log/nginx/error.log`.
|
If you encounter any errors, the Nginx log is located in `/var/log/nginx/error.log`.
|
||||||
|
|
||||||
### Finalize Nginx & Daphne setup
|
### Finalize Nginx & uvicorn setup
|
||||||
|
|
||||||
For testing purposes, Daphne exposes the Django application on port 8001.
|
For testing purposes, uvicorn exposes the Django application on port 8001.
|
||||||
A more elegant solution would be to expose the application using a Unix file socket.
|
A more elegant solution would be to expose the application using a Unix file socket.
|
||||||
|
|
||||||
Change `/etc/nginx/sites-available/etebase_nginx.conf` to accept file sockets by commenting in `server unix:///tmp/etebase_server.sock;` and commenting out `server 127.0.0.1:8001;`.
|
Change `/etc/nginx/sites-available/etebase_nginx.conf` to accept file sockets by commenting in `server unix:///tmp/etebase_server.sock;` and commenting out `server 127.0.0.1:8001;`.
|
||||||
@ -135,14 +113,14 @@ Now, we change the way we run Daphne to use the same file socket.
|
|||||||
|
|
||||||
```
|
```
|
||||||
$ systemctl restart nginx
|
$ systemctl restart nginx
|
||||||
$ daphne -u /tmp/etebase_server.sock etebase_server.asgi:application
|
$ uvicorn etebase_server.asgi:application --uds /tmp/etebase_server.sock
|
||||||
```
|
```
|
||||||
|
|
||||||
### That's it!
|
### That's it!
|
||||||
You now have a working Etebase server over HTTP.
|
You now have a working Etebase server over HTTP.
|
||||||
Don't forget to change `allowed_hosts` to your domain name in `etebase-server.ini` and to set `server_name` to your domain name in `/etc/nginx/sites-available/etebase_nginx.conf`.
|
Don't forget to change `allowed_hosts` to your domain name in `etebase-server.ini` and to set `server_name` to your domain name in `/etc/nginx/sites-available/etebase_nginx.conf`.
|
||||||
|
|
||||||
An optional next step is to have your Daphne run automatically at boot. More explanation can be found here: [Run Daphne at boot](https://github.com/etesync/server/wiki/Run-Daphne-at-boot)
|
An optional next step is to have your uvicorn run automatically at boot. More explanation can be found here: [Run uvicorn at boot](https://github.com/etesync/server/wiki/Run-uvicorn-at-boot)
|
||||||
|
|
||||||
It is also *highly* recommended **to enable TLS for your Etebase server!**
|
It is also *highly* recommended **to enable TLS for your Etebase server!**
|
||||||
A page detailing SSL setup can be found here: [Setup HTTPS for Etebase](https://github.com/etesync/server/wiki/Setup-HTTPS-for-Etebase)
|
A page detailing SSL setup can be found here: [Setup HTTPS for Etebase](https://github.com/etesync/server/wiki/Setup-HTTPS-for-Etebase)
|
Loading…
Reference in New Issue
Block a user