diff --git a/Production-setup-using-Daphne-and-Nginx.md b/Production-setup-using-Nginx.md similarity index 72% rename from Production-setup-using-Daphne-and-Nginx.md rename to Production-setup-using-Nginx.md index d2bc721..6c821a6 100644 --- a/Production-setup-using-Daphne-and-Nginx.md +++ b/Production-setup-using-Nginx.md @@ -1,5 +1,5 @@ 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. 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` -## 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 @@ -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 ln -s /etc/nginx/sites-available/etebase_nginx.conf /etc/nginx/sites-enabled/etebase_nginx.conf $ 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`. -### 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. 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 -$ daphne -u /tmp/etebase_server.sock etebase_server.asgi:application +$ uvicorn etebase_server.asgi:application --uds /tmp/etebase_server.sock ``` ### That's it! 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`. -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!** A page detailing SSL setup can be found here: [Setup HTTPS for Etebase](https://github.com/etesync/server/wiki/Setup-HTTPS-for-Etebase) \ No newline at end of file