diff --git a/docs/index.rst b/docs/index.rst index 180ef1ae..7c3d1424 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -28,6 +28,7 @@ Guides sanic/debug_mode sanic/testing sanic/deploying + sanic/nginx sanic/extensions sanic/examples sanic/changelog diff --git a/docs/sanic/config.rst b/docs/sanic/config.rst index 366d22d1..8b700956 100644 --- a/docs/sanic/config.rst +++ b/docs/sanic/config.rst @@ -238,9 +238,7 @@ Proxy config if using ... * a proxy that supports `forwarded`: set `FORWARDED_SECRET` to the value that the proxy inserts in the header * Apache Traffic Server: `CONFIG proxy.config.http.insert_forwarded STRING for|proto|host|by=_secret` * NGHTTPX: `nghttpx --add-forwarded=for,proto,host,by --forwarded-for=ip --forwarded-by=_secret` - * NGINX: after `the official instructions `_, add anywhere in your config: - -.. proxy_set_header Forwarded "$proxy_add_forwarded;by=\"_$server_name\";proto=$scheme;host=\"$http_host\";path=\"$request_uri\";secret=_secret"; + * NGINX: :ref:`nginx`. * a custom header with client IP: set `REAL_IP_HEADER` to the name of that header * `x-forwarded-for`: set `PROXIES_COUNT` to `1` for a single proxy, or a greater number to allow Sanic to select the correct IP diff --git a/docs/sanic/deploying.rst b/docs/sanic/deploying.rst index a0b4f1bb..55fae759 100644 --- a/docs/sanic/deploying.rst +++ b/docs/sanic/deploying.rst @@ -1,9 +1,12 @@ Deploying ========= -Deploying Sanic is very simple using one of three options: the inbuilt webserver, +Sanic has three serving options: the inbuilt webserver, an `ASGI webserver `_, or `gunicorn`. -It is also very common to place Sanic behind a reverse proxy, like `nginx`. + +Sanic's own webserver is the fastest option, and it can be securely run on +the Internet. Still, it is also very common to place Sanic behind a reverse +proxy, as shown in :ref:`nginx`. Running via Sanic webserver --------------------------- @@ -85,7 +88,11 @@ before shutdown, and after shutdown. Therefore, in ASGI mode, the startup and sh run consecutively and not actually around the server process beginning and ending (since that is now controlled by the ASGI server). Therefore, it is best to use `after_server_start` and `before_server_stop`. -3. ASGI mode is still in "beta" as of Sanic v19.6. + +Sanic has experimental support for running on `Trio `_ with:: + + hypercorn -k trio myapp:app + Running via Gunicorn -------------------- @@ -110,28 +117,6 @@ See the `Gunicorn Docs `_ + +Running as a service +~~~~~~~~~~~~~~~~~~~~ + +This part is for Linux distributions based on `systemd`. Create a unit file +`/etc/systemd/system/sanicexample.service`:: + + [Unit] + Description=Sanic Example + + [Service] + User=nobody + WorkingDirectory=/srv/sanicexample + ExecStart=/usr/bin/env python3 sanicexample.py + Restart=always + + [Install] + WantedBy=multi-user.target + +Then reload service files, start your service and enable it on boot:: + + sudo systemctl daemon-reload + sudo systemctl start sanicexample + sudo systemctl enable sanicexample