Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMD_URL_PATH not working #31

Open
TheAssassin opened this issue Apr 12, 2019 · 7 comments
Open

CMD_URL_PATH not working #31

TheAssassin opened this issue Apr 12, 2019 · 7 comments
Labels
bug Something isn't working

Comments

@TheAssassin
Copy link

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.

@SISheogorath
Copy link
Contributor

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 :)

@SISheogorath SISheogorath added the bug Something isn't working label Apr 12, 2019
@TheAssassin
Copy link
Author

TheAssassin commented Apr 12, 2019

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).

@nmaas87
Copy link

nmaas87 commented Apr 20, 2020

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?

@nmaas87
Copy link

nmaas87 commented Apr 20, 2020

REMOVED COMMENT: I commented on the wrong project, sorry!

@SISheogorath
Copy link
Contributor

@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.

@nmaas87
Copy link

nmaas87 commented Apr 20, 2020

@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 :(!

@SISheogorath
Copy link
Contributor

Yeah, that was never intended to be like that. We aim to solve that confusion with our version 2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants