Skip to content

Conversation

@Ayowel
Copy link

@Ayowel Ayowel commented Aug 18, 2025

With PLA 1, it is possible to host the application in a subpath (e.g.: /phpldapadmin) instead of at the root of a website. This MR tries to restore this behavior for easier/more natural migration from one version to the other.

Please provide feedback on the implementation choices, I'm unsure as to whether they are ideal or even standard.

With these changes, no specific configuration is required in PLA as long as the reverse proxy provides all needed headers.

Test nginx configuration (in assets/nginx.conf):

server {
        listen                  80;

        location /pla/ {
                absolute_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Forwarded-Port 7000;
                proxy_set_header X-Forwarded-Prefix "/pla";
                rewrite /pla/(.*) /$1 break;
                proxy_pass http://pla:8080;
        }
}

Test compose (in compose.yml, the repository is expected to be in the project directory):

services:
  nginx:
    container_name: nginx
    image: docker.io/nginx:1.29.1
    ports:
      - 7000:80
    volumes:
      - ./assets/nginx.conf:/etc/nginx/conf.d/default.conf:ro

  pla:
    container_name: pla
    image: docker.io/phpldapadmin/phpldapadmin:2.2.2
    user: "root"
    # userns_mode: keep-id:uid=82,gid=82
    environment:
      SITE_USER: "root"
      LDAP_HOST: ldap
      LDAP_PORT: 1389
      LDAP_BASE_DN: dc=example,dc=org
      LDAP_USERNAME: cn=admin,ou=users,dc=example,dc=org
      LDAP_LOGIN_ATTR: dn
      LDAP_PASSWORD: admin
      LOG_CHANNEL: stderr
      APP_UPDATE_CHECK: "true"
      # APP_DEBUG: true
    ports:
      - 7070:8080
    volumes:
      - ./project:/app:rw

  ldap:
    container_name: ldap
    image: docker.io/bitnami/openldap:2.6.10
    environment:
      LDAP_ADMIN_USERNAME: admin
      LDAP_ADMIN_PASSWORD: admin
      LDAP_USERS: user,admin
      LDAP_PASSWORDS: password,admin
      LDAP_ROOT: dc=example,dc=org
      LDAP_ADMIN_DN: cn=admin,ou=users,dc=example,dc=org

@Ayowel Ayowel marked this pull request as draft August 18, 2025 19:54
@Ayowel Ayowel changed the title Draft: Allow to host in a subpath Allow to host in a subpath Aug 18, 2025
* Add a base tag to use as a reference for PLA's subpath
* Update css urls to be relative to the css file's location
* Update Javascript URLs to use the base tag when preparing API requests
@Ayowel Ayowel marked this pull request as ready for review August 19, 2025 19:02
The CSS is already imported in app.css and the JS import takes
precedence and messes relative load locations required to be able to
host PLA with a prefix.
@Ayowel Ayowel force-pushed the feat/subpath-hosting branch from 552b83a to 0a22c7e Compare August 19, 2025 19:03
@Ayowel
Copy link
Author

Ayowel commented Aug 19, 2025

Seems ok to me, let me know if I need to make changes

@leenooks
Copy link
Owner

leenooks commented Aug 20, 2025

Hi @Ayowel - thanks for putting this together.

When I started out with v2, I did consider whether I would need to support running pla in a subpath, and went down the path of implementing root hosting to get something out the door quickly. (I wanted to stop the bug reports with 1.2 that I had no intention of addressing).

While I'm not sure of the use case for running PLA in a path, having all URI's relative is something that should be in place - which by definition should then support running PLA in a sub path.

I've not thought about the impacts of the work you've done and I think it would need to be fully tested this before merging it. I did start on the path of writing unit testing, and while that needs a lot more work, this might be the catalyst to complete it, or at least get the core methods tested.

I dont expect you to write the unit testing, but I'll do that first before merging this. So you will need to rebase this once I've got that done.

Appreciate your work - thank you.

@leenooks leenooks closed this in 725589a Sep 18, 2025
@leenooks
Copy link
Owner

Hi @Ayowel - thanks again for this PR.

Its taken me a bit of time to get this PR working correctly - hopefully I've nutted everything out. There were problems where I was able to get redirects working in a subpath, but it broke PLA when working in a root path (and visa versa).

I've updated the dev image that includes 725589a so feel free to try it out and let me know if you find anything still not working correctly.

@Ayowel
Copy link
Author

Ayowel commented Sep 23, 2025

After a quick test, this does not look ok.Using the provided compose.yml, I can login at http://127.0.0.1:7000/pla/ but the UI still appears to be broken.
I will try again later this week in case it is due to a mistake on my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants