Skip to main content

2 posts tagged with "nginx"

View All Tags

· One min read
Hreniuc Cristian-Alexandru

I needed this when I switched from kubernetes to docker compose(Kubernetes was too much to maintain and I only had one small project).

To load balance I used the following config for nginx:

upstream pool-of-services {
# Resolved by docker dns, so they must exist at nginx startup, othewise this fails
server container_1:6070;
server container_2:6070;
}

server {
# Listen to port 443 on both IPv4 and IPv6.
listen 443 ssl;
listen [::]:443 ssl;

location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://pool-of-services;
}
}

Source

· One min read
Hreniuc Cristian-Alexandru

To do so, I used jonasal/nginx-certbot docker image.

My docker compose file looked like this:

version: "3"
name: "nginx"
services:
nginx:
image: jonasal/nginx-certbot:3.3.1
container_name: nginx_prod_1
ports:
- 80:80
- 443:443
volumes:
- ./fs/nginx/secrets:/etc/letsencrypt:rw
- ./fs/nginx/log:/var/log/nginx:rw
- ./fs/nginx/user_conf.d:/etc/nginx/user_conf.d:ro
environment:
DEBUG: 1
CERTBOT_EMAIL: email
#STAGING: 1
restart: always