-
Notifications
You must be signed in to change notification settings - Fork 4
/
example.nginx.conf
51 lines (36 loc) · 1.05 KB
/
example.nginx.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
server {
server_name example.com;
set $app 'example';
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/example.com.crt;
ssl_certificate_key /etc/nginx/ssl/example.com.key;
root /srv/apps/$app/current/public;
try_files $uri @passenger;
# Maintenance
error_page 503 @503;
if (-f /srv/apps/$app/shared/system/maintenance.html) {
return 503;
}
location @503 {
# Serve static assets if found.
if (-f $request_filename) {
break;
}
# Set root to the public directory.
root /srv/apps/$app/current/public;
rewrite ^(.*)$ /system/maintenance.html break;
}
# Assets
location ~ ^/(assets)/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
# Backend server
location @passenger {
proxy_pass http://unix:/srv/apps/$app/passenger/app.sock:;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
}
}