Skip to content

Commit 55fbc64

Browse files
y82ADubhlaoich
andauthored
Updated example description for uwsgi and Django. (#552)
Co-authored-by: Alan Dooley <a.dooley@f5.com>
1 parent cea845d commit 55fbc64

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

content/nginx/admin-guide/web-server/app-gateway-uwsgi-django.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ Configuring the uWSGI application container itself is outside the scope of this
4141

4242
This example is illustrative only, and one way you might invoke your uWSGI server with Django:
4343

44-
```none
44+
```shell
45+
uwsgi \
4546
--chdir=/var/django/projects/myapp \
4647
--module=myapp.wsgi:application \
4748
--env DJANGO_SETTINGS_MODULE=myapp.settings \
@@ -60,38 +61,38 @@ With these options in place, here's a sample NGINX configuration for use with a
6061
```nginx
6162
http {
6263
# ...
63-
upstream django {
64-
server 127.0.0.1:29000;
64+
upstream django {
65+
server 127.0.0.1:29000;
6566
}
6667
6768
server {
68-
listen 80;
69-
server_name myapp.example.com;
70-
root /var/www/myapp/html;
71-
72-
location / {
73-
index index.html;
74-
}
75-
76-
location /static/ {
77-
alias /var/django/projects/myapp/static/;
78-
}
79-
80-
location /main {
81-
include /etc/nginx/uwsgi_params;
82-
uwsgi_pass django;
83-
uwsgi_param Host $host;
84-
uwsgi_param X-Real-IP $remote_addr;
85-
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
86-
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
87-
}
69+
listen 80;
70+
server_name myapp.example.com;
71+
root /var/www/myapp/html;
72+
73+
location / {
74+
index index.html;
75+
}
76+
77+
location /static/ {
78+
alias /var/django/projects/myapp/static/;
79+
}
80+
81+
location /main {
82+
include /etc/nginx/uwsgi_params;
83+
uwsgi_pass django;
84+
uwsgi_param Host $host;
85+
uwsgi_param X-Real-IP $remote_addr;
86+
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
87+
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
88+
}
8889
}
8990
}
9091
```
9192

92-
Notice that the configuration defines an upstream called Django, with a server containing the port number `29000`. It matches the port specified by the `socket` argument in the sample `uwsgi` command. The uWSGI server binds to this port.
93+
This configuration defines an upstream named `django`. The port number `29000` specified for the server in this upstream matches the port that the uWSGI server binds to, as specified by the `--socket=` argument in the sample `uwsgi` command.
9394

94-
NGINX or NGINX Plus serves static files from **/var/django/projects/myapp/static**. NGINX sends /main traffic to the Django app by converting it from HTTP to the uWSGI protocol.
95+
Serving static content is offloaded to NGINX or NGINX Plus, which serves it directly from `/var/django/projects/myapp/static`. Application traffic to the `/main` location is proxied and bridged from HTTP to the uwsgi protocol, and then passed to the Django app that runs within the uWSGI application container.
9596

9697
<span id="conclusion"></span>
9798
## Conclusion

0 commit comments

Comments
 (0)