-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxh.conf
116 lines (103 loc) · 4.1 KB
/
xh.conf
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Standardized XH-specific nginx settings. This config partial is copied into $XH_NGINX_CONFIG_PATH
# within this project's Dockerfile. From there it is included within the top-level `http` block,
# typically alongside an `app.conf` config file provided by the app (with app-specific location
# blocks and other settings).
# Support compression for both static assets and proxy calls
gzip on;
gzip_static on;
gzip_comp_level 2;
gzip_min_length 1000;
gzip_proxied any;
gzip_types application/json application/javascript text/css text/javascript;
# Increase client max body size to allow for larger uploads
client_max_body_size 100m;
# Increase proxy headers hash size due to our use of proxy_set_header - as per nginx msg in log.
proxy_headers_hash_max_size 1024;
# Convenience map to specify caching expiry by request type (use in expires directive as below)
map $sent_http_content_type $expires {
default off;
application/javascript max;
font/woff2 max;
image/png max;
text/css max;
text/html epoch;
}
# Determine the device type via UA sniffing for setting the $is_desktop, $is_mobile, and $is_tablet
# Snagged from https://gist.github.com/perusio/1326701#gistcomment-2009231 and is not guaranteed
# by any means to be perfect or exhaustive. Apps should use with care - we can tune if we have
# real-world cases where we find this is not working as desired.
map $http_user_agent $ua_device {
default 'desktop';
~*(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|mobile.+firefox|netfront|opera\ m(ob|in)i|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ ce|xda|xiino/i 'mobile';
~*android|ipad|playbook|silk/i 'tablet';
}
map $ua_device $is_mobile {
default 0;
mobile 1;
}
map $ua_device $is_tablet {
default 0;
tablet 1;
}
map $ua_device $is_desktop {
default 0;
desktop 1;
}
# Set new $xh_jespa_connection_id for use in xh-proxy include, where the resulting value is
# used to add/replace a Jespa-Connection-Id header. If request arrives with a Jespa-Connection-Id
# header already set, this map will re-use that same value: the incoming header is assumed to
# have been set by an upstream proxy or k8s ingress and to contain the actual client addr and port.
# Otherwise, we create the ID with the addr and port we know about here.
map $http_jespa_connection_id $xh_jespa_connection_id {
volatile;
default $http_jespa_connection_id;
"" $remote_addr:$remote_port;
}
# Ensure UTF8 charset spec'd in header, including for CSS files (which would not get a charset
# header by default). See https://github.com/xh/xh-nginx/issues/9 - rendering issue with icons.
charset utf-8;
charset_types text/html text/css text/xml text/plain text/vnd.wap.wml application/javascript application/rss+xml;
# App-level Dockerfiles must copy in an appropriate conf with server directives such as the below.
#server {
# server_name localhost;
# include includes/xh-secure-redirect.conf;
#}
#server {
# server_name localhost;
# listen 443 ssl;
# root /usr/share/nginx/html;
#
# # Redirect root to /app/
# location = / {
# return 301 $scheme://$host/app/;
# }
#
# # Static JS/CSS/etc assets not matching a more specific app selector below
# location / {
# expires $expires;
# }
#
# # App entry points - ensure trailing slash, try for match, fallback to app index for sub-routes
# location = /admin {
# return 301 $uri/;
# }
# location /admin/ {
# try_files $uri /admin/index.html;
# expires $expires;
# }
#
# location = /app {
# return 301 $uri/;
# }
# location /app/ {
# try_files $uri /app/index.html;
# expires $expires;
# }
#
# # Proxy to Grails back-end
# # Note this *requires* xh-tomcat to be defined by a docker swarm/link (or mocked via etc/hosts)
# location /api/ {
# proxy_pass http://xh-tomcat:8080/;
# include includes/xh-proxy.conf;
# }
#}