-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
181 lines (140 loc) · 5.75 KB
/
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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# Defines the number of worker processes.
worker_processes 1;
events {
# worker_processes and worker_connections allows you to calculate maxclients value:
# max_clients = worker_processes * worker_connections
worker_connections 1024;
}
http {
# Include default MIME types
include mime.types;
# Sets the default MIME type for files that doesn't have one
default_type application/octet-stream;
# By default, NGINX handles file transmission itself and copies the file into the buffer before sending it.
# Enabling the sendfile directive eliminates the step of copying the data into the buffer and enables direct copying
# data from one file descriptor to another.
sendfile on;
# Timeout during which a keep-alive client connection will stay open.
keepalive_timeout 65;
# A server block is a subset of Nginx’s configuration that defines a
# virtual server used to handle requests of a defined type.
# Deny all requests to top domain
server {
listen 80;
listen [::]:80;
server_name ~^(prod|preprod)\.silex\.artfx\.fr$;
deny all;
}
# Silex doc
server {
listen 80;
listen [::]:80;
server_name ~^docs\.(prod|preprod)\.silex\.artfx\.fr$;
resolver 127.0.0.11 valid=3s;
location / {
set $upstream http://silex-doc:80;
proxy_pass $upstream;
proxy_redirect off;
}
}
# Kitsu and Zou api
server {
# You would want to make a separate file with its own server block for each virtual domain
# on your server and then include them.
listen 80;
listen [::]:80;
# Lets you doname-based virtual hosting
server_name ~^kitsu\.(prod|preprod)\.silex\.artfx\.fr$;
location /api {
# Identifies the client's IP address.
# For the Load Balancing service, the "client" is the last remote peer.
proxy_set_header X-Real-IP $remote_addr;
# Sets the "Host" header to the $host variable,
# which should contain information about the original host being requested.
proxy_set_header Host $host;
# Include cors headers
include /etc/nginx/includes/cors_headers.conf;
# Sets the maximum allowed size of the client request body.
# If the size in a request exceeds the configured value, the 413 (Request Entity Too Large) error is returned to the client.
client_max_body_size 1G;
# The proxy_pass directive is mainly found in location contexts,
# and it sets the protocol and address of a proxied server.
# When a request matches a location with a proxy_pass directive inside,
# the request is forwarded to the URL given by the directive.
proxy_pass http://zou-app:5000/;
}
location /socket.io {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://zou-event:5001;
}
location / {
# The root directive specifies the root directory that will be used to search for a file.
root /opt/kitsu/dist;
# Solves 404 error with SPA routing
# See: https://stackoverflow.com/questions/45502403/nginx-proxy-pass-and-spa-routing-in-html5-mode
proxy_intercept_errors on;
error_page 404 = /index.html;
# Checks the existence of files in the specified order and
# uses the first found file for request processing.
# The processing is performed in the current context.
try_files $uri $uri/ /index.html;
}
# Redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# silex-front React application
server {
listen 80;
listen [::]:80;
server_name ~^front\.(prod|preprod)\.silex\.artfx\.fr$;
location / {
# The path is the destination of the React build in the Dockerfile
root /opt/silex/silex-front;
proxy_intercept_errors on;
error_page 404 = /index.html;
index index.html index.htm;
# Use this for Single Page Apps since routing is done on the client side
try_files $uri /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# harvest-ui / api
server {
listen 80;
listen [::]:80;
server_name ~^harvest\.(prod|preprod)\.silex\.artfx\.fr$;
location /api/ {
# Rewrite /api/something to /something
rewrite ^/api(/.*)$ $1 break;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
client_max_body_size 1G;
# Include cors headers
include /etc/nginx/includes/cors_headers.conf;
proxy_pass http://harvest-api:3000;
}
location / {
# The path is the destination of the React build in the Dockerfile
root /opt/silex/harvest-ui;
proxy_intercept_errors on;
error_page 404 = /index.html;
index index.html index.htm;
# Use this for Single Page Apps since routing is done on the client side
try_files $uri /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}