-
Notifications
You must be signed in to change notification settings - Fork 7
/
miller.nginx.conf.example
80 lines (65 loc) · 2.47 KB
/
miller.nginx.conf.example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# the upstream component nginx needs to connect to
upstream django {
server unix:///var/www/miller/miller.sock;
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name .example.com; # substitute your machine's IP address or FQDN
charset utf-8;
# enable access log
access_log /var/log/nginx/miller.access.log combined;
# max upload size
client_max_body_size 75M; # adjust to taste
location /robots.txt {
return 200 "User-agent: *\nDisallow: /static/\nDisallow: /media/\n";
}
# your Django project's static files, cfr miller/settings.js STATIC_ROOT
location /static {
alias /path/to/miller/dist;
}
# your Django project's media files, cfr miller/settings.js MEDIA_ROOT
location /media {
alias /path/to/miller/media;
location ~ /media/image{
# cropping service, root instead of alias;
root /path/to/miller;
try_files $uri $uri/ /services/images?url=$uri;
}
}
# the websocket config if daphne is using these args:
#`daphne miller.asgi:channel_layer --port 8001 -b 127.0.0.1`
location /ws {
proxy_pass http://127.0.0.1:8001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# Finally, send all non-media requests to the Django server.
location / {
# for js app.
set $prerender 0;
if ($http_user_agent ~* "google|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator") {
set $prerender 1;
}
if ($args ~ "_escaped_fragment_") {
set $prerender 1;
}
if ($request_uri ~ ^/accessibility) {
set $prerender 0;
}
# if needed, we use /accessibility endpoint to ser plain text contents to SEO and for better accessibility
if ($prerender = 1) {
rewrite ^/(.*)$ /accessibility/$1? break;
}
uwsgi_pass django;
proxy_pass_request_headers on;
proxy_no_cache $cookie_nocache $arg_nocache$arg_comment;
proxy_no_cache $http_pragma $http_authorization;
proxy_cache_bypass $cookie_nocache $arg_nocache $arg_comment;
proxy_cache_bypass $http_pragma $http_authorization;
include /path/to/miller/uwsgi_params; # the uwsgi_params file you installed
}
}