[mailcow] Move ejabberd site to last available site

This commit is contained in:
andryyy
2021-02-12 19:26:49 +01:00
parent 63160890e0
commit 8c6b512f05
8 changed files with 26 additions and 18 deletions

View File

@@ -71,6 +71,7 @@ cat <<EOF > /ejabberd/ejabberd_macros.yml
# Autogenerated by mailcow
define_macro:
'MAILCOW_HOSTNAME': "${MAILCOW_HOSTNAME}"
'EJABBERD_HTTPS': ${XMPP_HTTPS_PORT}
EOF
# Set open_basedir

View File

@@ -1,12 +1,12 @@
FROM php:7.4-fpm-alpine3.11
LABEL maintainer "Andre Peters <andre.peters@servercow.de>"
ENV APCU_PECL 5.1.18
ENV APCU_PECL 5.1.19
ENV IMAGICK_PECL 3.4.4
# Mailparse is pulled from master branch
#ENV MAILPARSE_PECL 3.0.2
ENV MEMCACHED_PECL 3.1.5
ENV REDIS_PECL 5.3.1
ENV REDIS_PECL 5.3.3
RUN apk add -U --no-cache autoconf \
aspell-dev \

View File

@@ -172,8 +172,8 @@ fi
# Fix permissions for global filters
chown -R 82:82 /global_sieve/*
[[ ! -f /etc/nginx/conf.d/ejabberd.conf ]] && echo '# Autogenerated by mailcow' > /etc/nginx/conf.d/ejabberd.conf
chown 82:82 /etc/nginx/conf.d/ejabberd.conf
[[ ! -f /etc/nginx/conf.d/ZZZ-ejabberd.conf ]] && echo '# Autogenerated by mailcow' > /etc/nginx/conf.d/ZZZ-ejabberd.conf
chown 82:82 /etc/nginx/conf.d/ZZZ-ejabberd.conf
# Run hooks
for file in /hooks/*; do

View File

@@ -53,13 +53,11 @@ listen:
module: ejabberd_s2s_in
max_stanza_size: 524288
-
port: 5443
port: EJABBERD_HTTPS
ip: "::"
module: ejabberd_http
tls: true
request_handlers:
/admin: ejabberd_web_admin
/api: mod_http_api
/captcha: ejabberd_captcha
/upload: mod_http_upload
/ws: ejabberd_http_ws
@@ -69,6 +67,7 @@ listen:
module: ejabberd_http
request_handlers:
/admin: ejabberd_web_admin
/api: mod_http_api
-
module: ejabberd_http
port: 5281
@@ -161,7 +160,6 @@ modules:
mod_fail2ban: {}
mod_http_api: {}
mod_http_upload:
put_url: https://@HOST@:5443/upload
docroot: /var/www/upload
custom_headers:
"Access-Control-Allow-Origin": "https://@HOST@"

View File

@@ -6,7 +6,7 @@ function xmpp_control($_action, $_data = null) {
case 'reload':
$curl = curl_init();
curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($curl, CURLOPT_URL, 'https://ejabberd:5443/api/reload_config');
curl_setopt($curl, CURLOPT_URL, 'http://ejabberd:5280/api/reload_config');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
@@ -32,7 +32,7 @@ function xmpp_control($_action, $_data = null) {
case 'restart':
$curl = curl_init();
curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($curl, CURLOPT_URL, 'https://ejabberd:5443/api/restart');
curl_setopt($curl, CURLOPT_URL, 'http://ejabberd:5280/api/restart');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
@@ -82,7 +82,7 @@ function xmpp_control($_action, $_data = null) {
) as $stat => $url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($curl, CURLOPT_URL, 'https://ejabberd:5443/api/' . $url);
curl_setopt($curl, CURLOPT_URL, 'http://ejabberd:5280/api/' . $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
@@ -128,10 +128,10 @@ function xmpp_rebuild_configs() {
touch('/ejabberd/ejabberd_hosts.yml');
touch('/ejabberd/ejabberd_acl.yml');
touch('/etc/nginx/conf.d/ejabberd.conf');
touch('/etc/nginx/conf.d/ZZZ-ejabberd.conf');
$ejabberd_hosts_md5 = md5_file('/ejabberd/ejabberd_hosts.yml');
$ejabberd_acl_md5 = md5_file('/ejabberd/ejabberd_acl.yml');
$ejabberd_site_md5 = md5_file('/etc/nginx/conf.d/ejabberd.conf');
$ejabberd_site_md5 = md5_file('/etc/nginx/conf.d/ZZZ-ejabberd.conf');
if (!empty($xmpp_domains)) {
// Handle hosts file
@@ -165,12 +165,12 @@ function xmpp_rebuild_configs() {
fclose($acl_handle);
// Handle Nginx site
$site_handle = @fopen('/etc/nginx/conf.d/ejabberd.conf', 'r+');
$site_handle = @fopen('/etc/nginx/conf.d/ZZZ-ejabberd.conf', 'r+');
if ($site_handle !== false) {
ftruncate($site_handle, 0);
fclose($site_handle);
}
$site_handle = fopen('/etc/nginx/conf.d/ejabberd.conf', 'w');
$site_handle = fopen('/etc/nginx/conf.d/ZZZ-ejabberd.conf', 'w');
if (!$site_handle) {
throw new Exception($lang['danger']['file_open_error']);
}
@@ -248,7 +248,7 @@ EOF;
);
}
if (md5_file('/etc/nginx/conf.d/ejabberd.conf') != $ejabberd_site_md5) {
if (md5_file('/etc/nginx/conf.d/ZZZ-ejabberd.conf') != $ejabberd_site_md5) {
$response = json_decode(docker('post', 'nginx-mailcow', 'exec', array("cmd" => "reload", "task" => "nginx"), 'Content-type: application/json'), true);
if (isset($response['type']) && $response['type'] == "success") {
$_SESSION['return'][] = array(