Skip to content

Commit

Permalink
Initial image resizer config for test server
Browse files Browse the repository at this point in the history
  • Loading branch information
FinemechanicPub committed Jul 28, 2023
1 parent 28d0f54 commit bf08ebc
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions infra_deploy/test/lubimovka_frontend_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
networks:
- test_nginx_network
volumes:
- ./nginx/nginx_top_test.conf:/etc/nginx/nginx.conf
- ./nginx/nginx_test.conf:/etc/nginx/conf.d/default.conf
- ./logs/nginx_logs/:/var/log/nginx/
- static_value_test:/config/test/static/
Expand Down
28 changes: 28 additions & 0 deletions infra_deploy/test/nginx/nginx_test.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# cache for resized images
proxy_cache_path cache/imgcache levels=1 keys_zone=resized:1m max_size=256m;

# main server block
server {
listen 80 default_server;
Expand Down Expand Up @@ -32,6 +35,12 @@ server {
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
}

location ~^/size([0-9]+)/media(?:/(.*))?$ {
proxy_pass http://127.0.0.1:9001;
proxy_cache resized;
proxy_cache_valid 180m;
}

location ~* /media/(.+\.txt)$ {
root /config/test/;
add_header Content-disposition "attachment; filename=$1";
Expand All @@ -43,6 +52,25 @@ server {

}


# server for image resizing

limit_req_zone "1" zone=2persec:32k rate=2r/s;

server {
listen 9001;
allow 127.0.0.1;
deny all;
limit_req zone=2persec burst=10;

location ~^/size([0-9]+)/media(?:/(.*))?$ {
alias /config/test/media/$2;
image_filter_buffer 10M;
image_filter resize $1 -;
}
}


# enable subdomain method reverse proxy confs
# include /config/nginx/proxy-confs/*.subdomain.conf;
# enable proxy cache for auth
Expand Down
33 changes: 33 additions & 0 deletions infra_deploy/test/nginx/nginx_top_test.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
load_module /etc/nginx/modules/ngx_http_image_filter_module.so; # image-filter module location in nginx docker image

user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}

0 comments on commit bf08ebc

Please sign in to comment.