lrsql
lrsql copied to clipboard
How to set up a URL base path with LRSQL_PROXY_PATH | proxyPath?
I want to set up LRSQL with an URL base path (/lrsql
) since there are other applications running on the host, but somehow I cannot get it running.
I found this in your documentation (https://yetanalytics.github.io/lrsql/env_vars.html):
|LRSQL_PROXY_PATH | proxyPath | This path modification is exclusively for use with a proxy, such as apache or nginx or a load balancer, where a path is added to prefix the entire application (such as https://www.mysystem.com/mylrs/xapi/statements). This does not actually change the routes of the application, it informs the admin frontend where to look for the server endpoints based on the proxied setup, and thus must be used in conjunction with a third party proxy. If used, the value must start with a leading / but not end with one (e.g. /mylrs is valid, as is /mylrs/b but /mylrs/ is not). Use with caution. | Not Set |
Can you please help me with the setup or point me at an example.
This is my docker-compose.yml to run the LRSQL:
services:
lrs:
image: yetanalytics/lrsql:v0.7.8
command:
- /lrsql/bin/run_postgres.sh
ports:
- "8080:8080"
depends_on:
- db
restart: always
environment:
LRSQL_API_KEY_DEFAULT: my_key
LRSQL_API_SECRET_DEFAULT: my_secret
LRSQL_ADMIN_USER_DEFAULT: my_username
LRSQL_ADMIN_PASS_DEFAULT: my_password
LRSQL_DB_HOST: db
LRSQL_DB_NAME: lrsql_db
LRSQL_DB_USER: lrsql_user
LRSQL_DB_PASSWORD: lrsql_password
# If Postgres is too slow to start, increase this
LRSQL_POOL_INITIALIZATION_FAIL_TIMEOUT: 10000
LRSQL_PROXY_PATH: /lrsql
db:
image: postgres:16.2
volumes:
- ./tmp/db:/var/lib/postgresql/data
environment:
POSTGRES_USER: lrsql_user
POSTGRES_PASSWORD: lrsql_password
POSTGRES_DB: lrsql_db
These are the relevant parts of my Apache reverse proxy configuration:
<VirtualHost *:443>
ServerName www.example.com
ProxyPass /lrsql http://localhost:8080/
ProxyPassReverse /lrsql http://localhost:8080/
</VirtualHost>
If I open the LRSQL page in the browser I get the login page but with some errors and I cannot login:
I'm running an Ubuntu 22.04, if it is relevant.
Hi Kristian,
At first glance I would say you actually setup the PROXY_PATH correctly. I believe your issue may instead be CORS related, because you are running it on example.com (I presume you are using /etc/hosts, and are not the ACTUAL owner of example.com haha).
Check out this table. You can either:
- broadly enable all origins (
LRSQL_ALLOW_ALL_ORIGINS
, less secure but super flexible) or - lock it down to specified ones (
LRSQL_ALLOWED_ORIGINS
, probably my recommendation for a production deployment)
Thanks, Cliff
Thank you for the LRSQL_ALLOW_ALL_ORIGINS
. This solved it for me.