Coder Social home page Coder Social logo

Comments (29)

xorguy avatar xorguy commented on May 28, 2024 1

Thanks to you!

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

Its not only assets. Everything in the code assumes / is the root.

I will take a look, see if it is feasible.

from madness.

xorguy avatar xorguy commented on May 28, 2024

The assets where faster to spot in browser developer tools that were called from root /.

Thanks!

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

I think I can make it happen. Will you be able to test it? Are you using the gem version or the Docker version?

from madness.

xorguy avatar xorguy commented on May 28, 2024

I think I can test it. I am using the Docker version.

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

Ok - I will prepare a docker edge release shortly.

from madness.

xorguy avatar xorguy commented on May 28, 2024

Ok, thanks.

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

I am having some difficulties with testing the new functionality due to how Sinatra works.

In the meantime, there is an edge docker image, which you can test like this:

# Pull the image
$ docker pull dannyben/madness:edge

# Create a madness_edge alias
$ alias madness_edge='docker run --rm -it --user $(id -u):$(id -g) --publish 3000:3000 --volume "$PWD:/app" dannyben/madness:edge'

# Create a .madness.yml file in the root of your documentation dir with this:
base_uri: /docs   # or whatever the proxy path is, no trailing slash.

then you should be able to run madness_edge server and have all documents and assets served from this path.

from madness.

xorguy avatar xorguy commented on May 28, 2024

Hi,
I tried to pull the new Docker image but it appears to be missing, shows error of manifest unknown. I checked at Docker Hub but I cannot see the tag.

Regards.

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

You are right. I fixed it now.

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

But wait with the test - I found out it is not ready yet when I started implementing specs.
I will post again when ready.

from madness.

xorguy avatar xorguy commented on May 28, 2024

I was trying with some setups in Caddy and was not working yet.
No hurries, whenever you can.

Thanks

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

If you have a simple docker-compose file with a caddy setup, it would be nice if you can share it so I can also test with a proxy.
I only tested without proxy, and never used caddy.

from madness.

xorguy avatar xorguy commented on May 28, 2024

Hi, sure.

This compose.yml for both Caddy and Madness:

services:
  caddy-md:
    image: caddy
    container_name: caddy-md
    restart: unless-stopped    
    environment:
      - PUID
      - PGID
    command: caddy run --config "/etc/caddy/Caddyfile" --adapter "caddyfile"
    expose:
      - "80"
      - "443"
    ports:
      - "80:80"
      - "443:443"
    volumes: 
      - ./data:/data
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./config:/config
      - ./docs:/usr/share/caddy
      - ./log:/var/log

  markdownserver:
    container_name: markdownserver
    image: dannyben/madness
    volumes: ["./docs:/docs"]
    ports: ["3000:3000"] # external port, not required when using reverse proxy
    expose: ["3000"] # expose port to internal docker network to be used by the reverse proxy
    command: server

This is the Caddyfile:

{
  debug
}

(webconf) {
  encode gzip
  header Permissions-Policy "interest-cohort=()" # Disable FLoC (Google)
}


http://fqdn {

  handle /handle_docs/* {
    reverse_proxy markdownserver:3000
    import webconf
  }

  handle_path /handle_path_docs/* {
    reverse_proxy markdownserver:3000
    import webconf
  }

  route /route_docs/* {
    reverse_proxy markdownserver:3000
    import webconf
  }

  route /route_strip_docs/* {
    uri strip_prefix /route_strip_docs
    reverse_proxy markdownserver:3000
    import webconf
  }

}

http://subdomain.fqdn {
  reverse_proxy markdownserver:3000
  import webconf
}

Replace fqdn with your own FQDN of the server or even the IP address, those are without SSL but one of the ideas to use the reverse proxy is to place under SSL, but that will not affect madness.
The file contains a domain plus 4 subpaths, those are different directives of Caddy with uri stripping and ones without but I think that using base_uri in Madness the valid ones will be route_docs and handle, because those maintain the subpath when requesting to the service, but included the others just in case.

You can download the files here:
Caddyfile
compose.yml

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

Ok - I managed to test it with a proxy, using the automated nginx reverse proxy, which I am more familiar with.

I have created a sample repo to demonstrate: https://github.com/DannyBen/dual-madness-sample

Note that the new edge docker uses the /docs folder to hold the docs, not /app. I did this so it is the same as the stable madness docker.

More info here

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

Wow - caddy is much less user friendly.

I have implemented with nginx before I saw your caddy config. So, I will skip caddy testing for now, as I see it is working properly with nginx - it should work with caddy if you follow the same principles.

Thanks for sharing in any case.

from madness.

xorguy avatar xorguy commented on May 28, 2024

Yes I know it is not the most user friendly reverse proxy.
Of course, keep using nginx that is far more easy. As you say, if it works in nginx then it should work with Caddy.

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

Cool. So I think the implementation is done, I will be waiting for your "real world test" results.

from madness.

xorguy avatar xorguy commented on May 28, 2024

So, I can try with Caddy? Pulling latest edge Docker image right?

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

Yes you can.

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

See my example repo, for reference on the important bits (see the docker compose file and the two .madness.yml files).

from madness.

xorguy avatar xorguy commented on May 28, 2024

Yes, I was looking at your example repo.

I tried with Caddy and is working as expected, with the handle directive and the base_uri at .madness.yml:
handle /docs/* { reverse_proxy markdownserver:3000 import webconf }

If you want to test anything else with Caddy let me know.

Thanks a lot.

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

Excellent.

Well - this was a bigger change than expected, and involved prepending the prefix URI in:

  1. Breadcrumbs
  2. Navigation bar links
  3. Search
  4. Assets

It also required completely changing how static assets are served.

So - if you can verify any/all of these are working for you as advertised, it can help in increasing the confidence in this release.

from madness.

xorguy avatar xorguy commented on May 28, 2024

Hi.
I've tested for a while and so far no problems found.

Only thing I found and is not related to the application is that when I tried your sample of md files, the TOC file contained the links with / and that when clicking the links it tried to load from root and not from subpath.

The fix was easy, just remove the / from the links at the TOC, leaving the links not starting with / worked perfectly.

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

I am unable to reproduce the problem. TOC - both on-page and the full site generated .md file - received the same treatment of prepended base_uri.

Which one are you talking about?

If you are talking about your own manually generated TOC, then yes - I am not handling any existing links, you will have to prepend the /docs prefix or make it relative - but I recommend letting madness generate site-wide toc with toc: Table of Contents in your settings.

from madness.

xorguy avatar xorguy commented on May 28, 2024

I mean the file from your sample folder (https://github.com/DannyBen/madness/blob/master/sample/Table%20of%20Contents.md).
So yes, it is a manually created one.

I tried with the madness generated one and it works flawlessly, and yes I will let madness create it.

from madness.

xorguy avatar xorguy commented on May 28, 2024

This is not related to that issue, but the Table of Contents that madness generates it is only updated when the container is restarted. I tried to add a subfolder and some more md files TOC only refreshed when restarted the container.

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

Oh - I forgot this sample exists. This is not manually generated, but rather generated with the toc: Table of Contents option.

But it is understandable that it does not work, since it was generated for a sample without a base_uri.

Ok - I will make a few more tweaks later and release.

from madness.

DannyBen avatar DannyBen commented on May 28, 2024

Version 1.1.0 is released with this change.

Thanks for the suggestion and participation.

from madness.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.