Skip to content

Commit be26834

Browse files
authored
Merge pull request #592 from CodeForPhilly/564-nginx-logging
564 nginx logging
2 parents 752af86 + 38dc99a commit be26834

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/client/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ RUN npm run build
2323
FROM nginx:latest AS host
2424

2525
# COPY nginx-client.conf /etc/nginx/conf.d/default.conf
26+
COPY nginx.conf /etc/nginx/nginx.conf
2627
COPY default.conf.template /etc/nginx/templates/
2728

2829
COPY --from=builder /app/build/ /usr/share/nginx/html

src/client/nginx.conf

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
user nginx;
2+
worker_processes auto;
3+
4+
error_log /var/log/nginx/error.log notice;
5+
pid /var/run/nginx.pid;
6+
7+
8+
events {
9+
worker_connections 1024;
10+
}
11+
12+
http {
13+
include /etc/nginx/mime.types;
14+
default_type application/octet-stream;
15+
16+
log_format json_combined escape=json
17+
'{'
18+
'"timestamp":"$msec",'
19+
'"address":"$remote_addr",'
20+
'"request":"$request",'
21+
'"body_bytes_sent":$body_bytes_sent,'
22+
'"response_status":$status,'
23+
'"http_user_agent":"$http_user_agent"'
24+
'}';
25+
26+
access_log /var/log/nginx/access.log json_combined;
27+
28+
sendfile on;
29+
30+
keepalive_timeout 65;
31+
32+
include /etc/nginx/conf.d/*.conf;
33+
34+
server {
35+
listen 80;
36+
server_name localhost;
37+
client_max_body_size 100M;
38+
39+
location ^~ /api/internal { # Blocks external access to /api/internal/*
40+
return 404;
41+
}
42+
43+
44+
45+
location / {
46+
root /usr/share/nginx/html;
47+
index index.html index.htm;
48+
try_files $uri /index.html; # forward all requests to the index.html for react
49+
}
50+
51+
location /api {
52+
try_files $uri @backend;
53+
}
54+
55+
location @backend {
56+
proxy_pass http://backend;
57+
proxy_set_header X-Real-IP $remote_addr;
58+
proxy_set_header Host $host;
59+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
60+
proxy_read_timeout 3600;
61+
proxy_connect_timeout 3600;
62+
proxy_send_timeout 3600;
63+
send_timeout 3600;
64+
}
65+
}
66+
}

0 commit comments

Comments
 (0)