Skip to content

Commit a8e554d

Browse files
authored
Merge pull request #938 from exadel-inc/add-nginx-conf
ERFS-1329 Deploy app to the Project envs [1.1.x]
2 parents 3fe7d5d + 5f9fcb0 commit a8e554d

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

dev/docker-compose.env.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#################################################################################################
2+
# Docker compose override file for deploy allication stack to the CompreFace project environments
3+
#
4+
# Usage: HOSTNAME=$HOSTNAME sudo docker-compose -f docker-compose.yml -f docker-compose.env.yml up -d
5+
#
6+
# Note: a) We need to provide $HOSTNAME to mount TLS certs correctly for each environment.
7+
# b) We also mount nginx configuration with HTTPS instead of the default one.
8+
#
9+
#################################################################################################
10+
version: '3.4'
11+
12+
volumes:
13+
postgres-data:
14+
15+
services:
16+
compreface-fe:
17+
volumes:
18+
- ./nginx/conf.d:/etc/nginx/conf.d:ro
19+
- /etc/letsencrypt/archive/$HOSTNAME/fullchain1.pem:/etc/nginx/ssl/fullchain.pem:ro
20+
- /etc/letsencrypt/archive/$HOSTNAME/privkey1.pem:/etc/nginx/ssl/privkey.pem:ro
21+
ports:
22+
- "8000:80"
23+
- "443:443"

dev/nginx/conf.d/nginx.conf

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
upstream frsadmin {
2+
server compreface-admin:8080 fail_timeout=10s max_fails=5;
3+
}
4+
5+
upstream frsapi {
6+
server compreface-api:8080 fail_timeout=10s max_fails=5;
7+
}
8+
9+
upstream frscore {
10+
server compreface-core:3000 fail_timeout=10s max_fails=5;
11+
}
12+
13+
server {
14+
listen 80;
15+
server_name ui;
16+
return 301 https://$host$request_uri;
17+
}
18+
19+
server {
20+
listen 443 ssl;
21+
server_name ui;
22+
ssl_certificate /etc/nginx/ssl/fullchain.pem;
23+
ssl_certificate_key /etc/nginx/ssl/privkey.pem;
24+
25+
client_max_body_size 10M;
26+
27+
location / {
28+
root /usr/share/nginx/html/;
29+
index index.html;
30+
try_files $uri $uri/ /index.html =404;
31+
}
32+
33+
location /admin/ {
34+
proxy_pass http://frsadmin/admin/;
35+
}
36+
37+
location /api/v1/ {
38+
39+
proxy_read_timeout 60000ms;
40+
proxy_connect_timeout 10000ms;
41+
42+
if ($request_method = 'OPTIONS') {
43+
add_header 'Access-Control-Allow-Origin' '*';
44+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
45+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,x-api-key';
46+
add_header 'Access-Control-Max-Age' 1728000;
47+
add_header 'Content-Type' 'text/plain; charset=UTF-8';
48+
add_header 'Content-Length' 0;
49+
return 204;
50+
}
51+
add_header 'Access-Control-Allow-Origin' '*' always;
52+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
53+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,x-api-key' always;
54+
55+
proxy_pass http://frsapi/api/v1/;
56+
}
57+
58+
location /core/ {
59+
if ($request_method = 'OPTIONS') {
60+
add_header 'Access-Control-Allow-Origin' '*';
61+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
62+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,x-api-key';
63+
add_header 'Access-Control-Max-Age' 1728000;
64+
add_header 'Content-Type' 'text/plain charset=UTF-8';
65+
add_header 'Content-Length' 0;
66+
return 204;
67+
}
68+
69+
add_header 'Access-Control-Allow-Origin' '*' always;
70+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
71+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,x-api-key' always;
72+
73+
proxy_pass http://frscore/;
74+
}
75+
76+
location ~ ^/(api|admin)/(swagger-ui.html|webjars|swagger-resources|v2/api-docs)(.*) {
77+
proxy_set_header 'Host' $http_host;
78+
proxy_pass http://frs$1/$2$3$is_args$args;
79+
}
80+
}

0 commit comments

Comments
 (0)