Hi all I am also facing a similar issue on DSpace 8.1. The backend API server logs "Access is denied. Invalid CSFR token" when log in with Safari and Firefox browsers. It does not logged in. But it works with Chrome.
To get it working on Safari, "Prevent crocs-site tracking" has to be unchecked. For Firefox, the backend url has to be added to the browser security/privacy setting to allow cookies and site data. The extra browser settings are not convenient for the end users. I am using separate VMs, frontend, backend, Solr and postgres. SSL has been configured for both. Nodejs on angular frontend running on http://localhost:4000, SSL with Nginx and tomcat on the backend on http://localhost:8080/server SSL with Apache. I have tested with following config in local.cfg in API backend rest.cors.allowed-origins = ${dspace.ui.url}, http://localhost:4000 proxies.trusted.ipranges = 127.0.0.1, real IP but, it didn't help.. Regards Senevi Herath On Sat, Apr 19, 2025 at 9:56 PM Hideyuki Mukai <[email protected]> wrote: > Hello dspace-tech list members, > > I am seeking help with a persistent issue installing DSpace 7.x using > Docker Compose. I am relatively new to DSpace and Docker. My goal is to get > a basic, functional DSpace instance running after several previous > unsuccessful attempts with other methods/versions. > > **Environment:** > * OS: Ubuntu 22.04 LTS (Fresh install, fully updated via apt) > * Platform: ConoHa VPS (Japan region, 12GB RAM) > * Docker: docker-ce 28.0.4, containerd.io 1.7.27 (Installed via official > Docker docs) > * Docker Compose: docker-compose-plugin 2.34.0 (Installed via official > Docker docs) > * Target DSpace Version: 7.6.3 (Latest stable identified from Release > Notes) > * Installation Method: Following "Try out DSpace 7" wiki page -> cloned > `DSpace/dspace-angular` repository (` > https://github.com/DSpace/dspace-angular.git` > <https://github.com/DSpace/dspace-angular.git>) into > `/root/dspace-angular` -> checked out `dspace-7_x` branch -> using > `docker/docker-compose.yml` and `docker/docker-compose-rest.yml` files > found within this `dspace-angular/docker` directory. > * Reverse Proxy: Apache 2 installed and configured to proxy `/` to ` > http://127.0.0.1:4000/` <http://127.0.0.1:4000/> and `/server/` to ` > http://127.0.0.1:8080/server/` <http://127.0.0.1:8080/server/> with > `ProxyPreserveHost On`. Firewall ports 80, 443 open (ufw & ConoHa panel). > HTTPS access uses a self-signed certificate for testing. > > **Current Status & Successes:** > * `docker compose -p d7 ... up -d` completes successfully. > * `docker compose ps` confirms all 4 containers (`dspace`, > `dspace-angular`, `dspacedb`, `dspacesolr`) are continuously `Up` and > running. > * Running `docker compose ... run --rm dspace-cli create-administrator -e > [email protected] ... -p admin ...` successfully creates an admin user. > * Running the AIP data ingest script (`docker compose ... run --rm > dspace-cli ...` using `cli.ingest.yml`) completes successfully, including > "Done with indexing". This suggests backend/DB/Solr are working internally. > > **The Persistent Problem:** > * Accessing the UI from an external PC browser using ` > http://160.251.230.95` (via Apache proxy) OR `https://160.251.230.95` > (via Apache proxy, bypassing self-signed cert warning) OR > `http://160.251.230.95:4000` (direct access, firewall port temporarily > opened) **all** result in an immediate redirect to `/500` displaying the > DSpace themed "500 Service unavailable" error page. Browser cache has been > cleared multiple times. > > **Key Diagnostics & Troubleshooting Done:** > > 1. **Browser Developer Console (Network/Console tabs):** Consistently > shows **CORS errors** when the UI loads, indicating the browser is blocking > requests from the frontend origin (e.g., `http://160.251.230.95`) to the > backend API origin (`http://160.251.230.95:8080`): > * `Access to XMLHttpRequest at ' > http://160.251.230.95:8080/server/api/security/csrf' from origin '...' > has been blocked by CORS policy: Response to preflight request doesn't pass > access control check: No 'Access-Control-Allow-Origin' header is present on > the requested resource.` > * Followed by `GET http://160.251.230.95:8080/server/api/security/csrf > net::ERR_FAILED`. > * Followed by JavaScript errors like `ERROR Error: undefined doesn't > contain the link authn`. > > 2. **Configuration Attempts (and Container Recreations):** > * Created `dspace.env` in `/root/dspace-angular` setting correct > public IPs for `DSPACE_HOSTNAME`, `DSPACE_SERVER_URL`, > `DSPACE_UI_HOSTNAME`, `DSPACE_UI_URL`, and setting `DSPACE_ALLOWED_ORIGINS` > to include `http://160.251.230.95:4000`, `http://localhost:4000`, ` > http://160.251.230.95`. Set `DSPACE_VER=dspace-7.6.3`, > `DSPACE_UI_VER=dspace-7.6.3`. Found this `.env` file was not automatically > used by the `dspace` service defined in `docker-compose-rest.yml`. > * Edited `docker/docker-compose-rest.yml` to explicitly set > `environment` variables using the `__P__` syntax based on that file's > existing structure: Added `rest__P__cors__P__allowed__P__origins=" > http://160.251.230.95:4000,http://localhost:4000,http://160.251.230.95"`, > and uncommented/set `dspace__P__server__P__url` and `dspace__P__ui__P__url` > with the public IP. Restarted `dspace` container. -> **Result: Still 500 > error / CORS block.** > > 3. **Direct Backend CORS Preflight Test:** > * Ran `curl -I -X OPTIONS -H "Origin: http://160.251.230.95" -H > "Access-Control-Request-Method: GET" -H "Access-Control-Request-Headers: > Authorization, Content-Type, X-XSRF-TOKEN" > http://127.0.0.1:8080/server/api/security/csrf` > <http://127.0.0.1:8080/server/api/security/csrf> from the host server. > * **Result:** Received **`HTTP/1.1 403 Forbidden`** and the response > headers **did not contain `Access-Control-Allow-Origin`**. This seems to > confirm the backend is not handling the CORS preflight correctly, despite > configuration attempts using the `__P__` environment variables in the > compose file. > > **My Specific Question:** > > Why is the DSpace backend (dspace container) apparently failing to handle > CORS preflight (OPTIONS) requests correctly and return the necessary > `Access-Control-Allow-Origin` header (resulting in a 403 response to > `curl`), even when the `rest__P__cors__P__allowed__P__origins` setting > seems correctly applied via the `docker-compose-rest.yml` environment block? > > Is there another layer of configuration (within Tomcat, Spring Security > filters, or DSpace's CORS Filter implementation) that might be overriding > or ignoring this setting? Are there known issues with DSpace 7.6.3 or the > specific Docker Compose files from the `dspace-angular` repository > regarding CORS or interaction with reverse proxies? What else can I check > or try to resolve this persistent CORS / 500 error? > > Any help or pointers would be greatly appreciated. Thank you very much for > your time and expertise. > > Sincerely, > > Hideyuki Mukai > > -- > All messages to this mailing list should adhere to the Code of Conduct: > https://www.lyrasis.org/about/Pages/Code-of-Conduct.aspx > --- > You received this message because you are subscribed to the Google Groups > "DSpace Technical Support" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion visit > https://groups.google.com/d/msgid/dspace-tech/156f32d1-fc15-4180-b7dd-19bdfe72efe6n%40googlegroups.com > <https://groups.google.com/d/msgid/dspace-tech/156f32d1-fc15-4180-b7dd-19bdfe72efe6n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- All messages to this mailing list should adhere to the Code of Conduct: https://www.lyrasis.org/about/Pages/Code-of-Conduct.aspx --- You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/dspace-tech/CAAkmSBm%3DL8P1Dmw_80dvO_S%2ByJspTAHZ4C0WMCLnJpvx8QMFAA%40mail.gmail.com.
