container
container copied to clipboard
CMD_URL_PATH not working
I've set CMD_URL_PATH to pad/ (also tried pad) in my docker-compose.yml, since I want to proxy from a different subdir.
This works partly; the screenshot for instance is loaded from https://my.domain.tld/pad//screenshot.png, but all other media is loaded from the root, e.g., https://my.domain.tld/build/cover-styles-pack.css.
I'm using NGINX, see the following config excerpt:
location ^~ /pad/ {
proxy_pass http://127.0.0.1:12345/;
include proxy_params;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
add_header X-Pad "test";
}
It's a pretty standard websocket-enabled proxy config.
I'm not sure if it's an issue of the infra in this repo (often, env vars are translated into config files by startup scripts), or needs to go into https://github.com/codimd/server.
This is a quite layered issue: First of all, yes, it seems like something got lost when refactoring towards webpack 4. The subdomain in general. This feature should come back, please open an issue for that in https://github.com/codimd/server.
For the container itself. there remains the problem, that at build time we already set the prefix to /. Which means you need to build the container yourself in order to have a URL_PATH. Let's make sure that we can make this rather trivial :)
For the container itself. there remains the problem, that at build time we already set the prefix to /. Which means you need to build the container yourself in order to have a URL_PATH. Let's make sure that we can make this rather trivial :)
@SISheogorath do you really need a prefix to render the files with? Normally, the problem inside the CSS or whatnot files is trivial to solve: relative paths in CSS files etc. are always relative to the file on the server, not to the current URL. So, just calculate the relative paths during build time. That's what most frameworks do, too, e.g., Bootstrap. If you can list which resources require the absolute path (and really, media stuff doesn't need it internally, most of the time you can just refer stuff from the HTML, and the HTML is rendered live anyway), I'll happily try to help find alternatives. We've all gone through this, haven't we?
Web frameworks like Flask allow for either using relative paths, or for calculating them on demand. If you really have to, you can temporarily render media files via the server.
I haven't tried the CDN option by the way. CDNs are evil, and not using them should be standard (i.e., opt-in instead of opt-out). </side-note>
This is a quite layered issue: First of all, yes, it seems like something got lost when refactoring towards webpack 4. The subdomain in general. This feature should come back, please open an issue for that in https://github.com/codimd/server.
I am not quite sure what you refer to. I am talking about subdirs, not subdomains. Did you mix up the two terms somehow?
I'm open to opening issues somewhere else, but only if I know what to write there. Might be easier if you just open an issue somewhere, I'll insert the information there then in a comment.
I just want to highlight that I will only be able to help on the Docker side of things, and in logical/conceptual things. I have a strong aversion towards JavaScript (especially backend stuff), and don't have enough rubber gloves here to even look into what's going on...
Edit: I would also suggest to rename this repo into docker or something else obvious, as this doesn't just contain the container, but also the deployment files for using the prebuilt ones. Makes this easier to find. I've found the old HackMD stuff first, and only today discovered this, although the time I last looked was not such a long time ago (couple weeks, maybe).
I see to have the same issue, using this docker-compose.yml with traefik:
codimd:
image: hackmdio/hackmd:2.0.1
restart: always
labels:
- "traefik.frontend.rule=PathPrefixStrip:/codimd"
- "traefik.port=3000"
- "traefik.docker.network=traefik"
environment:
- CMD_DB_URL=mysql://user:password@database/codimd
- CMD_PROTOCOL_USESSL=true
- CMD_URL_ADDPORT=false
- CMD_DOMAIN=test.example.com
- CMD_URL_PATH=codimd
- CMD_USECDN=flase
- CMD_AUTO_VERSION_CHECK=false
- CMD_ALLOW_ORIGIN=test.example.com, localhost
- CMD_ALLOW_GRAVATAR=false
- CMD_ALLOW_PDF_EXPORT=true
volumes:
- ./codimd/upload-data:/home/hackmd/app/public/uploads
the first thing which does not work, is that it tries to get https://test.example.com/config instead of https://test.example.com/codimd/config - so probably everything else fails afterwards, like trying to directly resolve the fonts folder - or in the "features" tab, it cannot connect to the socket- trying to access https://test.example.com/socket.io/?noteId.... instead of https://test.example.com/codimd/socket.io/?noteId.....
The config file contains the seetings, so it seems to be a bootstraping problem?
REMOVED COMMENT: I commented on the wrong project, sorry!
@nmaas87 As you might notice, you don't use our version of CodiMD, but the one maintained by the HackMD team. We can't help you with that. If you want us to support you, please use our container image or ask the HackMD team for support.
@SISheogorath Sorry, my bad. I just realizied. I was thrown of-course as both HackMD and you have a CodiMD project - however they are backed by other teams and have different versions and development status. Sorry for that :(!
Yeah, that was never intended to be like that. We aim to solve that confusion with our version 2.0.