Fixing #1435. imageproxy is now configured and loaded locally. The url is now /imageproxy and HAProxy knows to trim the url before sending it to the imageproxy service.

This commit is contained in:
Samuel Clay 2021-04-01 17:01:05 -04:00
parent 62e1172ef2
commit 64ac914db4
5 changed files with 30 additions and 5 deletions

View file

@ -22,7 +22,7 @@ nb:
- docker-compose exec newsblur_web ./manage.py loaddata config/fixtures/bootstrap.json
shell:
- - CURRENT_UID=${CURRENT_UID} CURRENT_GID=${CURRENT_GID} docker-compose exec newsblur_web ./manage.py shellplus
- - CURRENT_UID=${CURRENT_UID} CURRENT_GID=${CURRENT_GID} docker-compose exec newsblur_web ./manage.py shell_plus
# allows user to exec into newsblur_web and use pdb.
debug:
- newsblur := $(shell docker ps -qf "name=newsblur_web")

View file

@ -45,6 +45,16 @@ services:
volumes:
- node-files:/srv
imageproxy:
image: willnorris/imageproxy:latest
container_name: imageproxy
entrypoint: /app/imageproxy -addr 0.0.0.0:8088 -cache /tmp/imageproxy -verbose
restart: unless-stopped
ports:
- 8088:8088
volumes:
- /tmp:/tmp/imageproxy
nginx:
container_name: nginx
image: nginx:1.19.6
@ -92,9 +102,13 @@ services:
db_elasticsearch:
container_name: db_elasticsearch
image: elasticsearch:7.11.1
image: docker.elastic.co/elasticsearch/elasticsearch:7.11.1
mem_limit: 512mb
environment:
- discovery.type=single-node
ports:
- 9200:9200
- 9300:9300
volumes:
- ./docker/volumes/elasticsearch:/usr/share/elasticsearch/data
@ -130,11 +144,12 @@ services:
haproxy:
domainname: 'nb.local.com'
container_name: haproxy
image: haproxy:1.8.22
image: haproxy:latest
depends_on:
- nginx
- newsblur_web
- newsblur_node
- imageproxy
- db_redis
- db_postgres
- db_elasticsearch
@ -146,6 +161,7 @@ services:
volumes:
- ./docker/haproxy/haproxy.docker-compose.cfg:/usr/local/etc/haproxy/haproxy.cfg
- app-files:/srv/newsblur
netdata:
container_name: netdata
image: netdata/netdata
@ -162,6 +178,7 @@ services:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /etc/os-release:/host/etc/os-release:ro
volumes:
app-files:
driver: local

View file

@ -52,6 +52,7 @@ frontend public
use_backend node_favicon if { path_beg /rss_feeds/icon/ }
use_backend node_text if { path_beg /rss_feeds/original_text_fetcher }
use_backend node_page if { path_beg /original_page/ }
use_backend node_images if { path_beg /imageproxy/ }
use_backend nginx if { path_beg /media/ }
use_backend nginx if { path_beg /static/ }
use_backend nginx if { path_beg /favicon }
@ -63,6 +64,12 @@ frontend public
# use_backend gunicorn_refresh if is_refresh_feeds
use_backend gunicorn unless gunicorn_dead || nginx_dead
backend node_images
option httpchk HEAD /sc,sN1megONJiGNy-CCvqzVPTv-TWRhgSKhFlf61XAYESl4=/http:/samuelclay.com/static/images/2019%20-%20Cuba.jpg
http-check expect rstatus 200|301
http-request replace-path /imageproxy(.*) \1
server node_images imageproxy:8088 check inter 2000ms
backend node_socket
http-check expect rstatus 200|503
balance roundrobin

View file

@ -21,6 +21,7 @@ DOCKERBUILD = True
DEBUG = True
DEBUG_ASSETS = DEBUG
MEDIA_URL = '/media/'
IMAGES_URL = '/imageproxy'
SECRET_KEY = 'YOUR SECRET KEY'
AUTO_PREMIUM_NEW_USERS = True
AUTO_ENABLE_NEW_USERS = True

View file

@ -507,8 +507,8 @@
$share.addClass('NB-disabled').text('Sharing...');
this.feed = this.feed || {};
var scheme = {% if debug %}'http'{% else %}'https'{% endif %};
var url = scheme + '://' + this.domain + "{% url "api-share-story" token %}";
var scheme = '{% if debug %}http{% else %}https{% endif %}';
var url = scheme + '://' + this.domain + '{% url "api-share-story" token %}';
$.ajax({
url: url,