Browse Source

opendkim

tags/v1.0.0
Robin Thoni 7 years ago
parent
commit
0dce454866

+ 14
- 1
docker-compose.yml View File

48
                 aliases:
48
                 aliases:
49
                     - dovecot.internal.docker
49
                     - dovecot.internal.docker
50
         volumes:
50
         volumes:
51
-            - ./data/email:/var/email
51
+            - ./data/dovecot/email:/var/email
52
+            - ./data/dovecot/sieve:/etc/dovecot/sieve
52
         ports:
53
         ports:
53
             - "0.0.0.0:110:110"
54
             - "0.0.0.0:110:110"
54
             - "0.0.0.0:143:143"
55
             - "0.0.0.0:143:143"
58
         env_file:
59
         env_file:
59
             - env
60
             - env
60
 
61
 
62
+    opendkim:
63
+        build: ./opendkim
64
+        container_name: mx-opendkim
65
+        networks:
66
+            internal.docker:
67
+                aliases:
68
+                    - opendkim.internal.docker
69
+        volumes:
70
+            - ./data/opendkim/keys:/etc/opendkim/keys
71
+        env_file:
72
+            - env
73
+
61
 networks:
74
 networks:
62
     internal.docker:
75
     internal.docker:

+ 1
- 1
dovecot/Dockerfile View File

17
 
17
 
18
 COPY ./certs/ /etc/ssl/private/
18
 COPY ./certs/ /etc/ssl/private/
19
 
19
 
20
-VOLUME ["/var/email"]
20
+VOLUME ["/var/email", "/etc/dovecot/sieve"]
21
 
21
 
22
 EXPOSE 110 143 993 995 4190
22
 EXPOSE 110 143 993 995 4190
23
 
23
 

+ 2
- 4
dovecot/config/dovecot.conf View File

44
   # The path to the user's main active script. If ManageSieve is used, this the
44
   # The path to the user's main active script. If ManageSieve is used, this the
45
   # location of the symbolic link controlled by ManageSieve.
45
   # location of the symbolic link controlled by ManageSieve.
46
   sieve = ~/.dovecot.sieve
46
   sieve = ~/.dovecot.sieve
47
-  sieve_before = ~/sieve/01_vacation.sieve
48
-  sieve_extensions = +vacation +vacation-seconds
47
+  #sieve_before = ~/sieve/01_vacation.sieve
48
+  #sieve_extensions = +vacation +vacation-seconds
49
 
49
 
50
   # The default Sieve script when the user has none. This is a path to a global
50
   # The default Sieve script when the user has none. This is a path to a global
51
   # sieve script file, which gets executed ONLY if user's private Sieve script
51
   # sieve script file, which gets executed ONLY if user's private Sieve script
75
 postmaster_address = postmaster@example.org
75
 postmaster_address = postmaster@example.org
76
 
76
 
77
 service lmtp {
77
 service lmtp {
78
-  # Create inet listener only if you can't use the above UNIX socket
79
   inet_listener lmtp {
78
   inet_listener lmtp {
80
-    # Avoid making LMTP visible for the entire internet
81
     address = 0.0.0.0
79
     address = 0.0.0.0
82
     port = DOVECOT_LMTP_PORT
80
     port = DOVECOT_LMTP_PORT
83
   }
81
   }

+ 1
- 1
env View File

3
 POSTGRES_PASSWORD=pg_password
3
 POSTGRES_PASSWORD=pg_password
4
 POSTGRES_DB=postfixadmin
4
 POSTGRES_DB=postfixadmin
5
 
5
 
6
-MAIL_DOMAIN=test-mx.rthoni.com
6
+MAIL_DOMAIN=rthoni.com
7
 MAIL_HOSTNAME=vm01.rthoni.com
7
 MAIL_HOSTNAME=vm01.rthoni.com
8
 
8
 
9
 DOVECOT_HOST=dovecot.internal.docker
9
 DOVECOT_HOST=dovecot.internal.docker

+ 20
- 0
opendkim/Dockerfile View File

1
+FROM debian:jessie
2
+
3
+MAINTAINER Robin Thoni <robin@rthoni.com>
4
+
5
+RUN apt-get update &&\
6
+    apt-get install -y opendkim libopendbx1-pgsql rsyslog &&\
7
+    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
8
+
9
+RUN rm /etc/opendkim.conf &&\
10
+    ln -s /etc/opendkim/opendkim.conf /etc/opendkim.conf
11
+
12
+COPY ./run.sh /run.sh
13
+
14
+COPY ./config /etc/opendkim/
15
+
16
+RUN chown -R opendkim:opendkim /etc/opendkim
17
+
18
+VOLUME ["/etc/opendkim/keys"]
19
+
20
+CMD ["/run.sh"]

+ 21
- 0
opendkim/config.sql/opendkim.conf View File

1
+AutoRestart             Yes
2
+AutoRestartRate         10/1h
3
+UMask                   002
4
+Syslog                  yes
5
+SyslogSuccess           yes
6
+LogWhy                  Yes
7
+
8
+Canonicalization        relaxed/simple
9
+
10
+ExternalIgnoreList      dsn:pgsql://POSTGRES_USER:POSTGRES_PASSWORD@POSTGRES_HOST/POSTGRES_DB/table=dkim_external_ignore_list?keycol=host?datacol=host
11
+InternalHosts           dsn:pgsql://POSTGRES_USER:POSTGRES_PASSWORD@POSTGRES_HOST/POSTGRES_DB/table=dkim_internal_hosts?keycol=host?datacol=host
12
+KeyTable                dsn:pgsql://POSTGRES_USER:POSTGRES_PASSWORD@POSTGRES_HOST/POSTGRES_DB/table=dkim_key_table?keycol=name?datacol=key_path
13
+SigningTable            dsn:pgsql://POSTGRES_USER:POSTGRES_PASSWORD@POSTGRES_HOST/POSTGRES_DB/table=dkim_signing_table?keycol=email?datacol=name
14
+
15
+Mode                    sv
16
+PidFile                 /var/run/opendkim/opendkim.pid
17
+SignatureAlgorithm      rsa-sha256
18
+
19
+UserID                  opendkim:opendkim
20
+
21
+Socket                  inet:OPENDKIM_PORT@0.0.0.0

+ 1
- 0
opendkim/config/KeyTable View File

1
+all                  MAIL_DOMAIN:dkim:/etc/opendkim/dkim.private

+ 1
- 0
opendkim/config/SigningTable View File

1
+*                        all

+ 3
- 0
opendkim/config/TrustedHosts View File

1
+127.0.0.1
2
+localhost
3
+postfix.internal.docker

+ 15
- 0
opendkim/config/dkim.private View File

1
+-----BEGIN RSA PRIVATE KEY-----
2
+MIICWwIBAAKBgQCw8ztGcYIdp/fCfIjH0n5A6sKXKct0OfgVLLd8+Zj2zqmyhXFB
3
+7HI2zjQ2RBC6zqDS6VD8VWYX6pcWQNFdretjAm5Owmyd5SyRXxDwlVpyWLVHqGI2
4
+qHJR6cicAtBDSMtWGBLMSC8jR+44Dfzof53x1BlAPMr+Znj5yOS8fYQxwQIDAQAB
5
+AoGALROZOwW5ZsKeO/4rffPiU7k6HvX3rUEDMKm2iHCxBdZ5pk+WHXwVUF7RMC3A
6
+sUXn9DKZfd5nZppNKM8URrACcUbLx3g6Yj4LiupzasWn3IXf1nhbObHEIDcr821x
7
+Cs8v5kZhOHS9Wf03T1qOGkSLf3NL0MO6cXS1nBWkz/DL9R0CQQDikuYnybGTTB8c
8
+OzKW3d+hUt6u1JD4i8EGqvN9O4QSJrKgDHYGsx/EaicZLh7CM1CA/e2iH0weaBvL
9
+wuC3aflXAkEAx+5zBANxaWrpjyWVIMdmY9bxUjgBpRPgxbvFyctkqb58BpOkQpdn
10
+f2LvqxsblR9fDfZCduySSubTHPeS6bmGpwJAMBNfhr3DUi/qwgDFoUF+/CorWgl8
11
+oWB2GsYXWFFSms9fQ5qhSJalfPXRSgSBPk/JGzXGQIpHioQosbmuGP0BjQJAcQui
12
+fOJ1feW1qfrWF3KnskwWpyaDx5M1xJgnfbJDeLb76bwRZJW3L5ABc/4f2nGijYJw
13
+kk2xaiiZtgdGSmFcgQJAbG5PMgTBtAgawHtt8pqdojTDR3pJ3/Zc5vtCY+7MoWBA
14
+rHVixMuqodwxwgx/+OecEIdjF0SFkvTvKV0V2SeqXw==
15
+-----END RSA PRIVATE KEY-----

+ 2
- 0
opendkim/config/dkim.txt View File

1
+dkim._domainkey	IN	TXT	( "v=DKIM1; k=rsa; "
2
+	  "p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCw8ztGcYIdp/fCfIjH0n5A6sKXKct0OfgVLLd8+Zj2zqmyhXFB7HI2zjQ2RBC6zqDS6VD8VWYX6pcWQNFdretjAm5Owmyd5SyRXxDwlVpyWLVHqGI2qHJR6cicAtBDSMtWGBLMSC8jR+44Dfzof53x1BlAPMr+Znj5yOS8fYQxwQIDAQAB" )  ; ----- DKIM key dkim for rthoni.com

+ 21
- 0
opendkim/config/opendkim.conf View File

1
+AutoRestart             Yes
2
+AutoRestartRate         10/1h
3
+UMask                   002
4
+Syslog                  yes
5
+SyslogSuccess           Yes
6
+LogWhy                  Yes
7
+
8
+Canonicalization        relaxed/simple
9
+
10
+ExternalIgnoreList      refile:/etc/opendkim/TrustedHosts
11
+InternalHosts           refile:/etc/opendkim/TrustedHosts
12
+KeyTable                refile:/etc/opendkim/KeyTable
13
+SigningTable            refile:/etc/opendkim/SigningTable
14
+
15
+Mode                    sv
16
+PidFile                 /var/run/opendkim/opendkim.pid
17
+SignatureAlgorithm      rsa-sha256
18
+
19
+UserID                  opendkim:opendkim
20
+
21
+Socket                  inet:OPENDKIM_PORT@0.0.0.0

+ 18
- 0
opendkim/run.sh View File

1
+#! /usr/bin/env sh
2
+
3
+sed -e "s/POSTGRES_HOST/${POSTGRES_HOST}/" -i /etc/opendkim/opendkim.conf
4
+sed -e "s/POSTGRES_USER/${POSTGRES_USER}/" -i /etc/opendkim/opendkim.conf
5
+sed -e "s/POSTGRES_PASSWORD/${POSTGRES_PASSWORD}/" -i /etc/opendkim/opendkim.conf
6
+sed -e "s/POSTGRES_DB/${POSTGRES_DB}/" -i /etc/opendkim/opendkim.conf
7
+sed -e "s/OPENDKIM_PORT/${OPENDKIM_PORT}/" -i /etc/opendkim/opendkim.conf
8
+sed -e "s/MAIL_DOMAIN/${MAIL_DOMAIN}/" -i /etc/opendkim/KeyTable
9
+
10
+sleep 5
11
+
12
+rm -f /var/run/rsyslogd.pid
13
+rm -f /var/log/syslog
14
+service rsyslog start
15
+service opendkim start
16
+#/usr/sbin/opendkim -f -v -x /etc/opendkim.conf
17
+tail -f /var/log/syslog
18
+

+ 7
- 3
postfix/config/main.cf View File

83
 
83
 
84
 milter_default_action = accept
84
 milter_default_action = accept
85
 milter_protocol = 6
85
 milter_protocol = 6
86
-#smtpd_milters = inet:localhost:12345
87
-#non_smtpd_milters = inet:localhost:12345
88
-smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unknown_recipient_domain, reject_unauth_pipelining, reject_unauth_destination
86
+smtpd_milters = opendkim_12345
87
+non_smtpd_milters = opendkim_12345
88
+smtpd_relay_restrictions = permit_mynetworks,
89
+        permit_sasl_authenticated,
90
+        reject_unknown_recipient_domain,
91
+        reject_unauth_pipelining,
92
+        reject_unauth_destination

+ 3
- 0
postfix/run.sh View File

9
 postconf -e myhostname="${MAIL_HOSTNAME}"
9
 postconf -e myhostname="${MAIL_HOSTNAME}"
10
 postconf -e smtpd_sasl_path="inet:${DOVECOT_HOST}:${DOVECOT_SASL_PORT}"
10
 postconf -e smtpd_sasl_path="inet:${DOVECOT_HOST}:${DOVECOT_SASL_PORT}"
11
 postconf -e virtual_transport="lmtp:inet:${DOVECOT_HOST}:${DOVECOT_LMTP_PORT}"
11
 postconf -e virtual_transport="lmtp:inet:${DOVECOT_HOST}:${DOVECOT_LMTP_PORT}"
12
+postconf -e smtpd_milters="inet:${OPENDKIM_HOST}:${OPENDKIM_PORT}"
13
+postconf -e non_smtpd_milters="inet:${OPENDKIM_HOST}:${OPENDKIM_PORT}"
12
 
14
 
15
+rm -f /var/run/rsyslogd.pid
13
 service rsyslog start &&
16
 service rsyslog start &&
14
 service postfix start &&
17
 service postfix start &&
15
 
18
 

+ 0
- 1
postfixadmin/Dockerfile View File

30
 
30
 
31
 COPY ./postfixadmin-3.0/ /var/www/html/
31
 COPY ./postfixadmin-3.0/ /var/www/html/
32
 RUN chmod -R 777 /var/www/html/templates_c
32
 RUN chmod -R 777 /var/www/html/templates_c
33
-#VOLUME ["/var/www/html"]
34
 
33
 
35
 CMD ["/run.sh"]
34
 CMD ["/run.sh"]

+ 42
- 0
postgresql/docker-entrypoint-initdb.d/01_init.sql View File

816
 
816
 
817
 
817
 
818
 
818
 
819
+CREATE TABLE dkim_external_ignore_list (
820
+    host text NOT NULL
821
+);
822
+
823
+
824
+ALTER TABLE dkim_external_ignore_list OWNER TO dev;
825
+
826
+--
827
+-- Name: dkim_internal_hosts; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
828
+--
829
+
830
+CREATE TABLE dkim_internal_hosts (
831
+    host text NOT NULL
832
+);
833
+
834
+
835
+ALTER TABLE dkim_internal_hosts OWNER TO dev;
836
+
837
+--
838
+-- Name: dkim_key_table; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
839
+--
840
+
841
+CREATE TABLE dkim_key_table (
842
+    name text NOT NULL,
843
+    key_path text NOT NULL
844
+);
845
+
846
+
847
+ALTER TABLE dkim_key_table OWNER TO dev;
848
+
849
+--
850
+-- Name: dkim_signing_table; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
851
+--
852
+
853
+CREATE TABLE dkim_signing_table (
854
+    email text NOT NULL,
855
+    name text NOT NULL
856
+);
857
+
858
+ALTER TABLE ONLY dkim_signing_table
859
+    ADD CONSTRAINT dkim_signing_table_name_fkey FOREIGN KEY (name) REFERENCES dkim_key_table(name) ON UPDATE CASCADE ON DELETE CASCADE;
860
+
819
 
861
 
820
 --
862
 --
821
 -- PostgreSQL database dump complete
863
 -- PostgreSQL database dump complete

Loading…
Cancel
Save