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

Docker using MICOBIN_PUBLIC_PATH always results in 404 #108

Closed
ddimick opened this issue Nov 11, 2022 · 5 comments
Closed

Docker using MICOBIN_PUBLIC_PATH always results in 404 #108

ddimick opened this issue Nov 11, 2022 · 5 comments

Comments

@ddimick
Copy link

ddimick commented Nov 11, 2022

Everything seems to be right, but all links result in a 404 for what I presume is the paste section of the page. My.server.net is a valid domain, just modified for posting publicly here.

Browser outputs:
https://imgur.com/a/xtiF6Rs

HTML source in browser:

<!DOCTYPE html>
<html>
<head>
<title>MicroBin</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/svg+xml" href="https://my.server.net/microbin/static/favicon.svg">
<link rel="stylesheet" href="https://my.server.net/microbin/static/water.css">
</head>
<body style="
    max-width: 800px;
        margin: auto;
        padding-left:0.5rem;
        padding-right:0.5rem;
        line-height: 1.5;
        font-size: 1.1em;
        ">
<br>
<b style="margin-right: 0.5rem">

<img width=26 style="margin-bottom: -6px; margin-right: 0.5rem;" src="https://my.server.net/microbin/static/logo.png">
MicroBin
</b>
<a href="https://my.server.net/microbin/" style="margin-right: 0.5rem; margin-left: 0.5rem">New
</a>
<a href="https://my.server.net/microbin/pastalist" style="margin-right: 0.5rem; margin-left: 0.5rem">List</a>
<a href="https://my.server.net/microbin/info" style="margin-right: 0.5rem; margin-left: 0.5rem">Info</a>
<hr>
<br>
<h2>404</h2>
<b>Not Found</b>
<br>
<br>
<a href="https://my.server.net/microbin/"> Go Home</a>
<br>
<br>
<hr>
<p style="font-size: smaller">
<a href="https://microbin.eu">MicroBin</a> by Dániel Szabó and the FOSS Community.
Let's keep the Web <b>compact</b>, <b>accessible</b> and <b>humane</b>!
</p>
<script defer src="https://static.cloudflareinsights.com/beacon.min.js/vaafb692b2aea4879b33c060e79fe94621666317369993" integrity="sha512-0ahDYl866UMhKuYcW078ScMalXqtFJggm7TmlUtp0UlD4eQk0Ixfnm5ykXKvGJNFjLMoortdseTfsRT8oCfgGA==" data-cf-beacon='{"rayId":"7688a65829badb6e","version":"2022.11.0","r":1,"token":"a68b002d9558413dacf15687b65515ae","si":100}' crossorigin="anonymous"></script>
</body>
</html>

docker-compose.yaml

version: "3.7"

services:
  microbin:
    container_name: microbin
    hostname: microbin
    image: danielszabo99/microbin
    restart: always

    environment:
      - TZ
      - MICROBIN_HIGHLIGHT_SYNTAX=true
      - MICROBIN_EDITABLE=true
      - MICROBIN_ENABLE_BURN_AFTER=true
      - MICROBIN_PRIVATE=true
      - MICROBIN_QR=true
      - MICROBIN_PUBLIC_PATH=https://my.server.net/microbin

    labels:
      - "traefik.enable=true"

    networks:
      - traefik

    volumes:
      - ${PROJECT_PATH}/microbin/volumes:/app/pasta_data
@szabodanika
Copy link
Owner

szabodanika commented Nov 11, 2022

I think it's the /microbin/ path in your url it has issues with. Did you set up a reverse proxy to take /microbin/pasta to just /pasta for example? Because there is no /microbin/ path handled by MicroBin. You should probably set the public path to just https://my.server.net/

@ddimick
Copy link
Author

ddimick commented Nov 11, 2022

My reverse proxy (Traefik) is routing all URLs starting with https://my.server.net/microbin to the microbin Docker container. I had thought that setting the public path would allow such a configuration, for microbin to operate with a URI prefix in front of it?

Perhaps I also need to strip the /microbin prefix between my reverse proxy and the microbin container. I'll give that a try.

@szabodanika
Copy link
Owner

What the public path arg does is essentially just adjusting the outgoing links generated. It does not change what paths the server is listening to though. This is exactly for the use case when you want to use a path for microbin instead of a subdomain. Most people set it up as bin.server.net but with a custom public path and a reverse proxy you can do server.net/bin, but as you say you will need to strip that path from the requests

@ddimick
Copy link
Author

ddimick commented Nov 11, 2022

Ok, that makes sense, thank you for the fast response and explanation. Stripping the prefix between Traefik and microbin did indeed solve this problem. My working docker-compose.yaml is below, in case anyone else finds it useful.

version: "3.7"

services:
  microbin:
    container_name: microbin
    hostname: microbin
    image: danielszabo99/microbin
    restart: always

    environment:
      - TZ
      - MICROBIN_HIGHLIGHTSYNTAX=true
      - MICROBIN_EDITABLE=true
      - MICROBIN_ENABLE_BURN_AFTER=true
      - MICROBIN_PRIVATE=true
      - MICROBIN_QR=true
      - MICROBIN_PUBLIC_PATH=https://my.server.net/microbin

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.microbin.middlewares=microbin-addtrailingslash, microbin-stripprefix"
      - "traefik.http.middlewares.microbin-stripprefix.stripprefix.prefixes=/microbin"
      - "traefik.http.middlewares.microbin-addtrailingslash.redirectregex.regex=^(.*)\\/microbin$$" # without a trailing slash, submitting a new pasta from the landing page will return a 404
      - "traefik.http.middlewares.microbin-addtrailingslash.redirectregex.replacement=/microbin/"

    networks:
      - traefik

    volumes:
      - ${PROJECT_PATH}/microbin/volumes:/app/pasta_data

@szabodanika
Copy link
Owner

Nice! I will close this now, hopefully people will find this thread if they search on google, thanks for sharing your config. I will look into explaining this in the documentation as well, I am making some changes to it anyway.

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

No branches or pull requests

2 participants