DEVOPS-1892: added cache settings
moved from angie to nginx
This commit is contained in:
parent
14976c6156
commit
497aa37497
4 changed files with 114 additions and 88 deletions
110
config/nginx.conf
Normal file
110
config/nginx.conf
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
include /etc/nginx/modules-enabled.d/*.conf;
|
||||
|
||||
worker_processes 10;
|
||||
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
include /etc/nginx/conf-enabled.d/*.conf;
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
sendfile on;
|
||||
|
||||
gzip on;
|
||||
|
||||
# text/html doesn't need to be defined there, it's compressed always
|
||||
gzip_types text/plain text/css text/xml application/x-javascript application/atom+xml;
|
||||
|
||||
# gzip_comp_level 9;
|
||||
include /etc/nginx/sites-enabled.d/*.conf;
|
||||
|
||||
log_format nginx_main
|
||||
'$remote_addr - $remote_user [$time_local] $request '
|
||||
'"$status" $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for" '
|
||||
'"$request_filename" "$gzip_ratio" $upstream_response_time server: $host : $document_root $fastcgi_script_name ';
|
||||
|
||||
server {
|
||||
listen 80 default;
|
||||
|
||||
access_log /var/log/nginx/access.log nginx_main;
|
||||
error_log /var/log/nginx/error.log error;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
client_max_body_size 32m;
|
||||
|
||||
##
|
||||
# `gzip` Settings
|
||||
#
|
||||
#
|
||||
gzip on;
|
||||
gzip_disable "msie6";
|
||||
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_min_length 256;
|
||||
gzip_types
|
||||
application/atom+xml
|
||||
application/geo+json
|
||||
application/javascript
|
||||
application/x-javascript
|
||||
application/json
|
||||
application/ld+json
|
||||
application/manifest+json
|
||||
application/rdf+xml
|
||||
application/rss+xml
|
||||
application/xhtml+xml
|
||||
application/xml
|
||||
font/eot
|
||||
font/otf
|
||||
font/ttf
|
||||
image/svg+xml
|
||||
text/css
|
||||
text/javascript
|
||||
text/plain
|
||||
text/xml;
|
||||
|
||||
location / {
|
||||
root /frontend;
|
||||
index index.html;
|
||||
try_files $uri @index;
|
||||
|
||||
# Media: images, icons, video, audio, HTC
|
||||
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|mp3|ogg|ogv|webm|htc|woff2|woff|ttf)$ {
|
||||
expires 1M;
|
||||
access_log off;
|
||||
# max-age must be in seconds
|
||||
add_header Cache-Control "max-age=2629746, public";
|
||||
}
|
||||
# CSS and Javascript
|
||||
location ~* \.(?:css|js)$ {
|
||||
expires 1y;
|
||||
access_log off;
|
||||
add_header Cache-Control "max-age=31556952, public";
|
||||
}
|
||||
}
|
||||
|
||||
location @index {
|
||||
root /frontend;
|
||||
add_header Cache-Control no-cache;
|
||||
expires 0;
|
||||
try_files /index.html =404;
|
||||
}
|
||||
|
||||
location = /health {
|
||||
access_log off;
|
||||
add_header 'Content-Type' 'application/json';
|
||||
return 200 '{"status":"UP"}';
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue