Skip to content

Commit 002fa6c

Browse files
authored
docs: improve nginx example with HTTPS configuration (#2606)
* docs: improve nginx example with HTTPS configuration Update the NGINX example configuration in the deployment guide to include HTTPS support with HTTP-to-HTTPS redirect, which is the standard configuration for production deployments. Added: - HTTP to HTTPS redirect server block - SSL/TLS configuration with Let's Encrypt certificate paths - Mozilla Intermediate TLS configuration reference - Note about Mozilla SSL Configuration Generator - Note about simplifying for development (HTTP-only) Closes #1731 Signed-off-by: edvatar <88481784+toroleapinc@users.noreply.github.com> * fix rst reference for Let's Encrypt --------- Signed-off-by: edvatar <88481784+toroleapinc@users.noreply.github.com>
1 parent 42321c9 commit 002fa6c

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

docs/deploy/nginx-uwsgi.rst

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,22 +209,49 @@ platform <https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-n
209209

210210
Then, create an NGINX conf file that looks something like this:
211211

212-
.. code-block:: ini
212+
.. code-block:: nginx
213213
:caption: /etc/nginx/sites-available/myproject.conf
214214
215+
# Redirect HTTP to HTTPS
215216
server {
216217
listen 80;
217218
server_name myproject.com;
219+
return 301 https://$host$request_uri;
220+
}
221+
222+
server {
223+
listen 443 ssl;
224+
server_name myproject.com;
225+
226+
ssl_certificate /etc/letsencrypt/live/myproject.com/fullchain.pem;
227+
ssl_certificate_key /etc/letsencrypt/live/myproject.com/privkey.pem;
228+
229+
# Mozilla Intermediate configuration
230+
# https://ssl-config.mozilla.org/#server=nginx
231+
ssl_protocols TLSv1.2 TLSv1.3;
232+
ssl_prefer_server_ciphers off;
218233
219234
access_log /var/log/nginx/myproject-access.log;
220235
error_log /var/log/nginx/myproject-error.log warn;
221236
222237
location / {
223-
uwsgi_pass 127.0.0.1:8080
238+
uwsgi_pass 127.0.0.1:8080;
224239
include uwsgi_params;
225240
}
226241
}
227242
243+
.. note::
244+
245+
The above configuration includes HTTPS with a redirect from HTTP, using
246+
certificate paths typical of `Let's Encrypt`_. For a plain HTTP-only
247+
configuration (e.g., during development), you can simplify to a single
248+
``server`` block listening on port 80 without the ``ssl_*`` directives.
249+
250+
For production deployments, use the `Mozilla SSL Configuration Generator`_
251+
to generate a configuration tuned to your requirements.
252+
253+
.. _`Mozilla SSL Configuration Generator`: https://ssl-config.mozilla.org/#server=nginx
254+
228255
Finally, start (or restart) NGINX:
229256

230257
.. code-block:: sh
@@ -238,10 +265,9 @@ errors if the application does not start.
238265
Further Considerations
239266
''''''''''''''''''''''
240267

241-
We did not explain how to configure TLS (HTTPS) for NGINX, leaving that as an
242-
exercise for the reader. However, we do recommend using Let's Encrypt, which offers free,
243-
short-term certificates with auto-renewal. Visit the `Let’s Encrypt site`_ to learn
244-
how to integrate their service directly with NGINX.
268+
The NGINX configuration above includes TLS (HTTPS) using `Let's Encrypt`_, which
269+
offers free, short-term certificates with auto-renewal. Visit the `Let's Encrypt site`_
270+
to learn how to set up certificates for your domain.
245271

246272
In addition to setting up NGINX and uWSGI to run your application, you will of
247273
course need to deploy a database server or any other services required by your
@@ -251,4 +277,5 @@ the Falcon community is always happy to help with deployment questions, so
251277
`please don't hesitate to ask <https://falcon.readthedocs.io/en/stable/community/help.html#chat>`_.
252278

253279

254-
.. _`Let’s Encrypt site`: https://certbot.eff.org/
280+
.. _`Let's Encrypt`: https://letsencrypt.org/
281+
.. _`Let's Encrypt site`: https://certbot.eff.org/

0 commit comments

Comments
 (0)