Added sample apache conf.

Fixed fields (source column was not created/deleted when a new column was added/removed)
This commit is contained in:
Tomas Bures 2018-11-24 06:45:41 +01:00
parent 43c6b58793
commit 106acd0656
4 changed files with 108 additions and 15 deletions

View file

@ -550,6 +550,9 @@ async function create(context, listId, entity) {
table.index(columnName); table.index(columnName);
} }
}); });
// Altough this is a reference to another list, it is represented as signed int(11). This is because we use negative values for constant from SubscriptionSource
await knex.schema.raw('ALTER TABLE `subscription__' + listId + '` ADD `source_' + columnName +'` int(11) DEFAULT NULL');
} }
return id; return id;

View file

@ -250,6 +250,7 @@ async function migrateSubscriptions(knex) {
const info = await knex('subscription__' + list.id).columnInfo(); const info = await knex('subscription__' + list.id).columnInfo();
for (const field of fields) { for (const field of fields) {
if (field.column != null) { if (field.column != null) {
// Altough this is a reference to another list, it is represented as signed int(11). This is because we use negative values for constant from SubscriptionSource
await knex.schema.raw('ALTER TABLE `subscription__' + list.id + '` ADD `source_' + field.column +'` int(11) DEFAULT NULL'); await knex.schema.raw('ALTER TABLE `subscription__' + list.id + '` ADD `source_' + field.column +'` int(11) DEFAULT NULL');
} }
@ -1007,7 +1008,7 @@ async function migrateCampaigns(knex) {
' `ip` varchar(100) CHARACTER SET ascii DEFAULT NULL,\n' + ' `ip` varchar(100) CHARACTER SET ascii DEFAULT NULL,\n' +
' `device_type` varchar(50) DEFAULT NULL,\n' + ' `device_type` varchar(50) DEFAULT NULL,\n' +
' `country` varchar(2) CHARACTER SET ascii DEFAULT NULL,\n' + ' `country` varchar(2) CHARACTER SET ascii DEFAULT NULL,\n' +
' `count` int(11) unsigned NOT NULL DEFAULT \'1\',\n' + ' `count` int(10) unsigned NOT NULL DEFAULT \'1\',\n' +
' `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n' + ' `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n' +
' PRIMARY KEY (`campaign`, `list`,`subscription`,`link`),\n' + ' PRIMARY KEY (`campaign`, `list`,`subscription`,`link`),\n' +
' KEY `created_index` (`created`)\n' + ' KEY `created_index` (`created`)\n' +
@ -1174,8 +1175,8 @@ async function migrateTriggers(knex) {
await knex.schema.raw('CREATE TABLE `trigger_messages` (\n' + await knex.schema.raw('CREATE TABLE `trigger_messages` (\n' +
' `trigger` int(10) unsigned NOT NULL,\n' + ' `trigger` int(10) unsigned NOT NULL,\n' +
' `list` int(11) unsigned NOT NULL,\n' + ' `list` int(10) unsigned NOT NULL,\n' +
' `subscription` int(11) unsigned NOT NULL,\n' + ' `subscription` int(10) unsigned NOT NULL,\n' +
' `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n' + ' `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n' +
' PRIMARY KEY (`trigger`, `list`,`subscription`)\n' + ' PRIMARY KEY (`trigger`, `list`,`subscription`)\n' +
') ENGINE=InnoDB DEFAULT CHARSET=utf8;\n'); ') ENGINE=InnoDB DEFAULT CHARSET=utf8;\n');

View file

@ -0,0 +1,101 @@
# This example sets up virtual domains for mailtrain protected by HTTPS (including redirect from http to https)
# Note that you will need mod_proxy and mod_ssl modules installed and enabled
# This setup assumes three DNS names:
# - mail.example.org - public endpoint used for subscriptions, campaign images, etc.
# - mailtrain.example.org - UI for administration and send out emails
# - sbox.mailtrain.example.org - sandbox for templates (to prevent potential XSS attacks in templates)
# It is OK to point all the three DNS entries to the same IP address
# You will need to customize this for your setup. In the least, this means:
# - replace "example.org" with your domain
# - point to your certificate (look for /etc/letsencrypt/live/mail.example.org in the config below)
<VirtualHost mail.example.org:80>
ServerName mail.example.org
ServerSignature Off
RewriteEngine On
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
ErrorLog logs/mail.example.org_redirect_error.log
LogLevel warn
</VirtualHost>
<VirtualHost mailtrain.example.org:80>
ServerName mailtrain.example.org
ServerSignature Off
RewriteEngine On
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
ErrorLog logs/mailtrain.example.org_redirect_error.log
LogLevel warn
</VirtualHost>
<VirtualHost sbox.mailtrain.example.org:80>
ServerName sbox.mailtrain.example.org
ServerSignature Off
RewriteEngine On
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
ErrorLog logs/sbox.mailtrain.example.org_redirect_error.log
LogLevel warn
</VirtualHost>
<VirtualHost mail.example.org:443>
ServerName mail.example.org:443
ErrorLog logs/mail.example.org_ssl_error.log
TransferLog logs/mail.example.org_ssl_access.log
LogLevel warn
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/mail.example.org/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mail.example.org/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/mail.example.org/chain.pem
ProxyPreserveHost On
ProxyPass "/" "http://127.0.0.1:3004/"
ProxyPassReverse "/" "http://127.0.0.1:3004/"
</VirtualHost>
<VirtualHost mailtrain.example.org:443>
ServerName mailtrain.example.org:443
ErrorLog logs/mailtrain.example.org_ssl_error.log
TransferLog logs/mailtrain.example.org_ssl_access.log
LogLevel warn
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/mail.example.org/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mail.example.org/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/mail.example.org/chain.pem
ProxyPreserveHost On
ProxyPass "/" "http://127.0.0.1:3000/"
ProxyPassReverse "/" "http://127.0.0.1:3000/"
</VirtualHost>
<VirtualHost sbox.mailtrain.example.org:443>
ServerName sbox.mailtrain.example.org:443
ErrorLog logs/sbox.mailtrain.example.org_ssl_error.log
TransferLog logs/sbox.mailtrain.example.org_ssl_access.log
LogLevel warn
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/mail.example.org/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mail.example.org/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/mail.example.org/chain.pem
ProxyPreserveHost On
ProxyPass "/" "http://127.0.0.1:3003/"
ProxyPassReverse "/" "http://127.0.0.1:3003/"
</VirtualHost>

View file

@ -1,12 +0,0 @@
# This example sets up mailtrain.org/www.mailtrain.org virtual domains
# for Apache2 and proxies requests for these domains to localhost port 3000
# Using mod_proxy is not enabled by default, so you probably need to do this yourself
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass "/" "http://127.0.0.1:3000/"
ProxyPassReverse "/" "http://127.0.0.1:3000/"
ServerName mailtrain.org
ServerAlias www.mailtrain.org
</VirtualHost>