Skip to content

Commit eefb4e8

Browse files
authored
feat: support HTTPS for Solr Admin, fixes #33 (#53)
1 parent ad874bb commit eefb4e8

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This add-on integrates Solr for Drupal 9+ into your [DDEV](https://ddev.com/) pr
3434
* Under "Advanced server configuration" set the "solr.install.dir" to `/opt/solr`.
3535
6. `ddev restart`
3636

37-
## Outdated Solr config files
37+
### Outdated Solr config files
3838

3939
If you get a message about Solr having outdated config files, you need to update the included Solr config files.
4040

@@ -46,6 +46,15 @@ If you get a message about Solr having outdated config files, you need to update
4646

4747
See [the documentation in the `doc` folder](doc/README.md)
4848

49+
## Usage
50+
51+
| Command | Description |
52+
| ------- | ----------- |
53+
| `ddev launch :8943` | Open Solr Admin (HTTPS) in your browser (`https://<project>.ddev.site:8943`) |
54+
| `ddev launch :8983` | Open Solr Admin (HTTP) in your browser (`http://<project>.ddev.site:8983`) |
55+
| `ddev describe` | View service status and used ports for Solr |
56+
| `ddev logs -s solr` | Check Solr logs |
57+
4958
## Explanation
5059

5160
This is the classic Drupal `solr:8` image recipe used for a long time by Drupal users and compatible with `search_api_solr`.
@@ -56,9 +65,9 @@ This is the classic Drupal `solr:8` image recipe used for a long time by Drupal
5665

5766
## Interacting with Apache Solr
5867

59-
* The Solr admin interface will be accessible at: `http://<projectname>.ddev.site:8983/solr/` For example, if the project is named `myproject` the hostname will be: `http://myproject.ddev.site:8983/solr/`.
68+
* The Solr Admin interface will be accessible at: `https://<projectname>.ddev.site:8943/solr/` and `http://<projectname>.ddev.site:8983/solr/`. For example, if the project is named `myproject` the hostname will be: `https://myproject.ddev.site:8943/solr/`.
6069
* To access the Solr container from inside the web container use: `http://solr:8983/solr/`
61-
* A Solr core is automatically created by default with the name "dev"; it can be accessed (from inside the web container) at the URL: `http://solr:8983/solr/dev` or from the host at `http://<projectname>.ddev.site:8983/solr/#/~cores/dev`. You can obviously create other cores to meet your needs.
70+
* A Solr core is automatically created by default with the name "dev"; it can be accessed (from inside the web container) at the URL: `http://solr:8983/solr/dev` or from the host at `https://<projectname>.ddev.site:8943/solr/#/~cores/dev`. You can obviously create other cores to meet your needs.
6271

6372
## Alternate Core Name
6473

@@ -74,7 +83,7 @@ services:
7483
1. Change `SOLR_CORENAME` environment variable in the `environment:` section.
7584
2. Change your Drupal configuration to use the new core.
7685

77-
You can delete the "dev" core from `http://<projectname>.ddev.site:8983/solr/#/~cores/dev` by clicking "Unload".
86+
You can delete the "dev" core from `https://<projectname>.ddev.site:8943/solr/#/~cores/dev` by clicking "Unload".
7887

7988
## Multiple Solr Cores
8089

docker-compose.solr.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,34 @@ services:
3131
# and code at https://github.com/docker-solr/docker-solr
3232
# README: https://github.com/docker-solr/docker-solr/blob/master/README.md
3333
# It's almost impossible to work with it if you don't read the docs there
34-
image: solr:8
34+
build:
35+
dockerfile_inline: |
36+
ARG SOLR_BASE_IMAGE="scratch"
37+
FROM $$SOLR_BASE_IMAGE
38+
# Fix HTTPS redirect to HTTP which breaks URL for Solr Admin UI.
39+
# The reason for this problem is that Solr uses Jetty as a webserver.
40+
# Jetty has X-Forwarded- headers disabled by default, enable them here:
41+
USER root
42+
RUN sed -i '/X-Forwarded-/,/-->/ {/<!--/d; /-->/d}' /opt/solr/server/etc/jetty.xml
43+
USER solr
44+
args:
45+
SOLR_BASE_IMAGE: ${SOLR_BASE_IMAGE:-solr:8}
3546
restart: "no"
3647
# Solr is served from this port inside the container.
3748
expose:
3849
- 8983
3950
# These labels ensure this service is discoverable by ddev.
4051
labels:
4152
com.ddev.site-name: ${DDEV_SITENAME}
42-
com.ddev.approot: $DDEV_APPROOT
53+
com.ddev.approot: ${DDEV_APPROOT}
4354
environment:
4455
# This defines the host name the service should be accessible from. This
4556
# will be sitename.ddev.site.
4657
- VIRTUAL_HOST=$DDEV_HOSTNAME
4758
# HTTP_EXPOSE exposes http traffic from the container port 8983
4859
# to the host port 8983 vid ddev-router reverse proxy.
4960
- HTTP_EXPOSE=8983:8983
61+
- HTTPS_EXPOSE=8943:8983
5062
volumes:
5163
# solr core *data* is stored on the 'solr' docker volume
5264
# This mount is optional; without it your search index disappears
@@ -60,6 +72,7 @@ services:
6072
- ./solr:/solr-conf
6173

6274
- ".:/mnt/ddev_config"
75+
- ddev-global-cache:/mnt/ddev-global-cache
6376

6477
# solr-configupdate.sh copies fresh configuration files into the
6578
# solr container on each
@@ -70,7 +83,7 @@ services:
7083

7184
# The odd need to use $$SOLR_CORENAME here is explained in
7285
# https://stackoverflow.com/a/48189916/215713
73-
entrypoint: 'bash -c "VERBOSE=yes docker-entrypoint.sh solr-precreate $${SOLR_CORENAME:-dev} /solr-conf"'
86+
entrypoint: 'bash -c "VERBOSE=yes docker-entrypoint.sh solr-precreate $${SOLR_CORENAME:-dev} /solr-conf"'
7487

7588
external_links:
7689
- "ddev-router:${DDEV_SITENAME}.${DDEV_TLD}"

tests/test.bats

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ health_checks() {
5252

5353
run ddev drush search-api-solr:reload default_solr_server
5454
assert_success
55+
56+
# Make sure the solr admin UI via HTTP from outside is redirected to HTTP /solr/
57+
run curl -sfI http://${PROJNAME}.ddev.site:8983
58+
assert_success
59+
assert_output --partial "HTTP/1.1 302"
60+
assert_output --partial "Location: http://${PROJNAME}.ddev.site:8983/solr/"
61+
62+
# Make sure the solr admin UI via HTTPS from outside is redirected to HTTPS /solr/
63+
run curl -sfI https://${PROJNAME}.ddev.site:8943
64+
assert_success
65+
assert_output --partial "HTTP/2 302"
66+
assert_output --partial "location: https://${PROJNAME}.ddev.site:8943/solr/"
67+
68+
# Make sure the solr admin UI is working from outside
69+
run curl -sfL https://${PROJNAME}.ddev.site:8943
70+
assert_success
71+
assert_output --partial "Solr Admin"
5572
}
5673

5774
teardown() {

0 commit comments

Comments
 (0)