Skip to content

Allow to use host + alias instead of multiple hosts #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ Be sure to view the following repositories to understand all the customizable op
| Parameter | Description | Default |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------- |
| `SETUP_TYPE` | Automatically generate configuration with defaults. Set to `MANUAL` and map the configuration file to use your own | `AUTO` |
| `ALLOWED_HOSTS` | Set which domains which can access service Seperate Multiple with `,` - Example: `https://www.example\.org` (no wildcards) | `` |
| `ALLOWED_HOSTS` | Set which domains which can access service Seperate Multiple with `,` - Example: `https://www\.example\.org` (no wildcards) | `` |
| `ALLOWED_HOST` | Set a domain which can access service - Example: `https://www\.example\.org` (no wildcards). Prevent the use of `ALLOWED_HOSTS` | `` |
| `ALLOWED_ALIAS` | Set a regex for alias which can access service - Example: `https://.*\.example\.org`. Requires the use of `ALLOWED_HOST` | `` |
| `EXTRA_OPTIONS` | If you want to pass additional arguments upon startup, add it here | `` |
| `INTERFACE` | Web interface type `classic` or `notebookbar` | `notebookbar` |
| `WATERMARK_OPACITY` | Watermark Opacity | `0.2` |
Expand Down
23 changes: 17 additions & 6 deletions install/etc/cont-init.d/10-coolwsd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ prepare_service single
prepare_service 03-monitoring
PROCESS_NAME="collabora-online"

sanity_var "ALLOWED_HOSTS" "Allowed Hostnames"
[[ -z $ALLOWED_HOST ]] && sanity_var "ALLOWED_HOSTS" "Allowed Hostnames"

print_debug "Creating directories and setting up logging"
mkdir -p "${LOG_PATH}"
Expand Down Expand Up @@ -220,11 +220,22 @@ if [ "${SETUP_TYPE,,}" = "auto" ]; then

### Allowed Hosts
sed -i -e 's|<alias_groups \(.*\) mode=.*>|<alias_groups \1 mode="groups">|' /etc/coolwsd/coolwsd.xml
allowed_hosts=$(echo "${ALLOWED_HOSTS}" | tr "," "\n")
for host in $allowed_hosts; do
print_info "Adding Allowed Host: ${host}"
sed -i "/<alias_groups .*>/a \ <group><host desc=\"hostname to allow or deny.\" allow=\"true\">${host}</host></group>" /etc/coolwsd/coolwsd.xml
done
if [ -n "$ALLOWED_HOST" ]
then
print_info "Adding Allowed Host: ${ALLOWED_HOST}"
if [ -n "$ALLOWED_ALIAS" ]
then
print_info "Adding Allowed Host: ${ALLOWED_ALIAS}"
ALLOWED_ALIAS="<alias desc=\"\">${ALLOWED_ALIAS}</alias>"
fi
sed -i "/<alias_groups .*>/a \ <group><host desc=\"hostname to allow or deny.\" allow=\"true\">${ALLOWED_HOST}</host>${ALLOWED_ALIAS}</group>" /etc/coolwsd/coolwsd.xml
else
allowed_hosts=$(echo "${ALLOWED_HOSTS}" | tr "," "\n")
for host in $allowed_hosts; do
print_info "Adding Allowed Host: ${host}"
sed -i "/<alias_groups .*>/a \ <group><host desc=\"hostname to allow or deny.\" allow=\"true\">${host}</host></group>" /etc/coolwsd/coolwsd.xml
done
fi
fi

# Generate WOPI proof key
Expand Down