philomena/docker/web/nginx.conf

112 lines
2.7 KiB
Nginx Configuration File
Raw Normal View History

2019-12-03 03:04:59 +01:00
upstream philomena {
2019-12-03 23:56:26 +01:00
server app:4000 fail_timeout=0;
2019-12-03 03:04:59 +01:00
}
2022-02-09 03:32:12 +01:00
upstream s3 {
server files:80 fail_timeout=0;
}
2022-02-11 01:13:14 +01:00
map $uri $custom_content_type {
default "text/html";
~(.*\.png)$ "image/png";
~(.*\.jpe?g)$ "image/jpeg";
~(.*\.gif)$ "image/gif";
~(.*\.svg)$ "image/svg+xml";
~(.*\.mp4)$ "video/mp4";
~(.*\.webm)$ "video/webm";
}
2019-12-03 03:04:59 +01:00
server {
listen 80 default;
listen [::]:80;
root $APP_DIR/priv/static;
2020-10-21 20:10:11 +02:00
client_max_body_size 125000000;
2020-04-03 02:46:12 +02:00
client_body_buffer_size 128k;
2020-05-29 02:55:58 +02:00
location ~ ^/img/view/(.+)/([0-9]+).*\.([A-Za-z0-9]+)$ {
2019-12-03 03:04:59 +01:00
expires max;
add_header Cache-Control public;
2022-02-09 03:32:12 +01:00
proxy_pass http://s3/$BUCKET_NAME/images/$1/$2/full.$3;
2022-02-11 01:13:14 +01:00
proxy_hide_header Content-Type;
add_header Content-Type $custom_content_type;
2019-12-03 03:04:59 +01:00
}
2020-05-29 02:55:58 +02:00
location ~ ^/img/download/(.+)/([0-9]+).*\.([A-Za-z0-9]+)$ {
2019-12-03 03:04:59 +01:00
add_header Content-Disposition "attachment";
expires max;
add_header Cache-Control public;
2022-02-09 03:32:12 +01:00
proxy_pass http://s3/$BUCKET_NAME/images/$1/$2/full.$3;
2022-02-11 01:13:14 +01:00
proxy_hide_header Content-Type;
add_header Content-Type $custom_content_type;
2022-02-09 03:32:12 +01:00
}
location ~ ^/img/(.+) {
expires max;
add_header Cache-Control public;
proxy_pass http://s3/$BUCKET_NAME/images/$1;
2022-02-11 01:13:14 +01:00
proxy_hide_header Content-Type;
add_header Content-Type $custom_content_type;
2019-12-03 03:04:59 +01:00
}
2022-02-09 03:32:12 +01:00
location ~ ^/spns/(.+) {
2019-12-03 03:04:59 +01:00
expires max;
add_header Cache-Control public;
2022-02-09 03:32:12 +01:00
proxy_pass http://s3/$BUCKET_NAME/adverts/$1;
2022-02-11 01:13:14 +01:00
proxy_hide_header Content-Type;
add_header Content-Type $custom_content_type;
2019-12-03 03:04:59 +01:00
}
2022-02-09 03:32:12 +01:00
location ~ ^/avatars/(.+) {
2019-12-03 03:04:59 +01:00
expires max;
add_header Cache-Control public;
2022-02-09 03:32:12 +01:00
proxy_pass http://s3/$BUCKET_NAME/avatars/$1;
2022-02-11 01:13:14 +01:00
proxy_hide_header Content-Type;
add_header Content-Type $custom_content_type;
2019-12-03 03:04:59 +01:00
}
2022-02-11 01:17:53 +01:00
location ~ ^/badge-img/(.+) {
2019-12-03 03:04:59 +01:00
expires max;
add_header Cache-Control public;
2022-02-09 03:32:12 +01:00
proxy_pass http://s3/$BUCKET_NAME/badges/$1;
2022-02-11 01:13:14 +01:00
proxy_hide_header Content-Type;
add_header Content-Type $custom_content_type;
2019-12-03 03:04:59 +01:00
}
2022-02-11 01:17:53 +01:00
location ~ ^/tag-img/(.+) {
2019-12-03 03:04:59 +01:00
expires max;
add_header Cache-Control public;
2022-02-09 03:32:12 +01:00
proxy_pass http://s3/$BUCKET_NAME/tags/$1;
2022-02-11 01:13:14 +01:00
proxy_hide_header Content-Type;
add_header Content-Type $custom_content_type;
2019-12-03 03:04:59 +01:00
}
location / {
try_files $uri @proxy;
}
location @proxy {
proxy_pass http://philomena;
proxy_redirect off;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
# Configuration for Phoenix WS
2020-06-12 18:56:11 +02:00
proxy_http_version 1.1;
2019-12-03 03:04:59 +01:00
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}