Skip to content

Commit

Permalink
Adiciona NGINX com configuração para redimensionar imagens
Browse files Browse the repository at this point in the history
  • Loading branch information
edvaldoszy committed Jul 19, 2024
1 parent 45b3a86 commit 45fa5b5
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,13 @@ services:
- --default-time-zone=+00:00
- --character-set-server=utf8mb4
- --sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

nginx:
image: nginx:1.17-alpine
container_name: herbario_nginx
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/conf.d:/etc/nginx/conf.d
- ./uploads:/usr/share/nginx/html
ports:
- 8080:80
72 changes: 72 additions & 0 deletions nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
server {
listen 80;
server_name localhost;

#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

location ~ ^/images/(?<file_path>.+)/resize$ {
set $width -;
set $height -;

if ($arg_width) {
set $width $arg_width;
}
if ($arg_height) {
set $height $arg_height;
}

alias /usr/share/nginx/html/$file_path;

image_filter resize $width $height;
image_filter_buffer 10M;
image_filter_interlace on;
image_filter_jpeg_quality 85;
image_filter_sharpen 0.5;

expires 1y;
}

location /images {
alias /usr/share/nginx/html;

expires 1y;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
33 changes: 33 additions & 0 deletions nginx/nginx.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;

user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log warn;
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 45fa5b5

Please sign in to comment.