Reputation: 4621
I run iRedMail in Docker container using the following image lejmr/iredmail-docker According official instruction it can be started as
docker run -p 8079:80 -p 442:443 \
-h mail.my-site.com \
-e "MYSQL_ROOT_PASSWORD=pwd" \
-e "SOGO_WORKERS=1" \
-e "TZ=Europe/Moscow" \
-e "POSTMASTER_PASSWORD={SSHA512}postpwd" \
-e "IREDAPD_PLUGINS=['reject_null_sender', 'reject_sender_login_mismatch', 'throttle', 'amavisd_wblist', 'sql_alias_access_policy']" \
-v /srv/iredmail/mysql:/var/lib/mysql \
-v /srv/iredmail/vmail:/var/vmail \
-v /srv/iredmail/clamav:/var/lib/clamav \
--name=iredmail lejmr/iredmail:mysql-latest
The above command works fine, I can see running docker container in terminal, all services started correctly.
I want to pass requests to the mail server through first proxy as plain http and than handle https connection in docker container lejmr/iredmail-docker.
Here is my nginx.conf, which do not redirect to iredmail site at all.
Any idea on how to pass http mail traffic to mail server running in docker on the host?
load_module /usr/lib/nginx/modules/ngx_stream_module.so;
user www-data;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
upstream mail {
server 127.0.0.1:8079 fail_timeout=0;
}
server {
server_name mail.my-site.com;
listen 80;
location / {
# Use internal Docker DNS resolver IP
# Internal AWS DNS resolver IP is your AWS VPC network range plus two
resolver 127.0.0.11 valid=30s;
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_set_header X-Forwarded-Proto $scheme;
proxy_redirect http:// https://;
# Define upstream in variable to resolve 502 Bad Gateway error if the host is unavailable
set $upstream_mail mail;
proxy_pass http://$upstream_mail;
# Required for new HTTP-based CLI
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_buffering off; # Required for HTTP-based CLI to work over SSL
}
}
# another modules with ssl behind this proxy
include /etc/nginx/sites-enabled/*.conf;
server_names_hash_bucket_size 64;
}
Upvotes: 1
Views: 1646