Skip to content

Commit

Permalink
Fix #27 Allow user to change SSL port (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
romandemidov authored and agolybev committed Jan 17, 2020
1 parent 1146dbd commit 8862ff1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -137,6 +137,14 @@ If you want to return ONLYOFFICE Document Server to work on HTTP, delete files f
# snap restart onlyoffice-ds
```

#### Running ONLYOFFICE Document Server on Different SSL Port

By default, HTTPS SSL port is 443. If you'd like to change it (say, to port 444), run:

```
# snap set onlyoffice-ds onlyoffice.ds-ssl-port=444
```

#### JSON Web Token

- **jwt-enabled**: Specifies the enabling the JSON Web Token validation by the ONLYOFFICE Document Server. Defaults to `false`.
Expand Down
2 changes: 2 additions & 0 deletions bin/nginx-start.sh
Expand Up @@ -65,7 +65,9 @@ update_nginx_settings(){
configure_ds_port(){
sed -i -e "s#\/etc\/nginx#${SNAP_DATA}\/etc\/nginx#g" ${NGINX_ONLYOFFICE_CONF}
DS_PORT=$(snapctl get onlyoffice.ds-port)
DSS_PORT=$(snapctl get onlyoffice.ds-ssl-port)
sed -i "s/80/"${DS_PORT}"/g" $SNAP_DATA/etc/onlyoffice/documentserver/nginx/ds.conf
sed -i "s/443/"${DSS_PORT}"/g" $SNAP_DATA/etc/onlyoffice/documentserver/nginx/ds.conf
cp -f ${NGINX_ONLYOFFICE_CONF} $SNAP_DATA/etc/nginx/conf.d/ds.conf
}

Expand Down
36 changes: 35 additions & 1 deletion snap/hooks/configure
Expand Up @@ -2,6 +2,7 @@

cp $SNAP/my.cnf $SNAP_DATA/mysql/my.cnf
DEFAULT_HTTP_PORT="80"
DEFAULT_HTTPS_PORT="443"
DEFAULT_DB_PORT="3306"
DEFAULT_JWT_ENABLED="false"
DEFAULT_JWT_SECRET="secret"
Expand All @@ -13,12 +14,20 @@ nginx_onlyoffice_http_port()
onlyoffice_http_port="$(onlyoffice_http_port)"
previous_onlyoffice_http_port="$(previous_onlyoffice_http_port)"

onlyoffice_https_port="$(onlyoffice_https_port)"
previous_onlyoffice_https_port="$(previous_onlyoffice_https_port)"

# If no changes were requested, then there's nothing to do here.
if [ "$onlyoffice_http_port" = "$previous_onlyoffice_http_port" ]; then
if [ "$onlyoffice_http_port" = "$previous_onlyoffice_http_port" && "$onlyoffice_https_port" = "$previous_onlyoffice_https_port" ]; then
return 0
fi

set_onlyoffice_http_port "$onlyoffice_http_port"
set_previous_onlyoffice_http_port $onlyoffice_http_port

set_onlyoffice_https_port "$onlyoffice_https_port"
set_previous_onlyoffice_https_port $onlyoffice_https_port

snapctl restart onlyoffice-ds.nginx
}

Expand Down Expand Up @@ -49,7 +58,32 @@ set_previous_onlyoffice_http_port()
snapctl set private.onlyoffice.ds-port="$1"
}

set_onlyoffice_https_port()
{
snapctl set onlyoffice.ds-ssl-port="$1"
}

onlyoffice_https_port()
{
sport="$(snapctl get onlyoffice.ds-ssl-port)"
if [ -z "$sport" ]; then
sport="$DEFAULT_HTTPS_PORT"
set_onlyoffice_https_port $sport
set_previous_onlyoffice_https_port $sport
fi

echo "$sport"
}

previous_onlyoffice_https_port()
{
snapctl get private.onlyoffice.ds-ssl-port
}

set_previous_onlyoffice_https_port()
{
snapctl set private.onlyoffice.ds-ssl-port="$1"
}


db_onlyoffice_db_port()
Expand Down

0 comments on commit 8862ff1

Please sign in to comment.