Skip to content

Instantly share code, notes, and snippets.

@chetan
Created April 20, 2021 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chetan/f79017065b5ba371c9b2610c35bacacd to your computer and use it in GitHub Desktop.
Save chetan/f79017065b5ba371c9b2610c35bacacd to your computer and use it in GitHub Desktop.
meshcentral docker setup with traefik reverse proxy serving TLS
// write this config file at /var/homelabos/meshcentral/data/config.json
{
"$schema": "http://info.meshcentral.com/downloads/meshcentral-config-schema.json",
"settings": {
"cert": "meshcentral.example.com",
"WANonly": true,
"_LANonly": true,
"_sessionKey": "MyReallySecretPassword1",
"port": 80,
"_aliasPort": 443,
"redirPort": 81,
"_redirAliasPort": 80,
"AgentPong": 300,
"TLSOffload": true,
"SelfUpdate": false,
"AllowFraming": true,
"WebRTC": false,
"IgnoreAgentHashCheck": false,
"log": "debug"
},
"domains": {
"": {
"_title": "MyServer",
"_title2": "Servername",
"_minify": true,
"certurl": "https://meshcentral.example.com:443",
"NewAccounts": "false",
"_userNameIsEmail": true
}
},
"_letsencrypt": {
"__comment__": "Requires NodeJS 8.x or better, Go to https://letsdebug.net/ first before>",
"_email": "myemail@mydomain.com",
"_names": "myserver.mydomain.com",
"production": false
}
}
# Add the following service to your compose file (or a new one)
meshcentral:
image: typhonragewind/meshcentral
restart: always
environment:
- HOSTNAME=meshcentral.example.com
- REVERSE_PROXY=true
- REVERSE_PROXY_TLS_PORT=
- IFRAME=true
- ALLOW_NEW_ACCOUNTS=false
- WEBRTC=false
volumes:
- /var/homelabos/meshcentral/data:/opt/meshcentral/meshcentral-data
- /var/homelabos/meshcentral/files:/opt/meshcentral/meshcentral-files
labels:
- "traefik.enable=true"
- "traefik.http.routers.meshcentral.rule=Host(`meshcentral.example.com`)"
- "traefik.http.routers.meshcentral.middlewares=sslRedir@file"
- "traefik.http.routers.meshcentral.tls=true"
- "traefik.http.routers.meshcentral.tls.certresolver=default"
- "traefik.http.services.meshcentral.loadbalancer.server.scheme=http"
- "traefik.http.services.meshcentral.loadbalancer.server.port=80"
@silversurfer98
Copy link

Can you please show what is the sslRedir@file configs are ?, I'm trying to make mesh central work with traefik but all in vain, Thank you

@chetan
Copy link
Author

chetan commented Oct 9, 2023

@silversurfer98 it's a fairly simple middleware, mostly to upshift from http to https but I also tacked on a few other things over the years.

http:
  middlewares:
    sslRedir:
      headers:
        stsSeconds: 315360000
        stsIncludeSubdomains: true
        contentSecurityPolicy: "frame-ancestors 'self' https://my.domain.com"
        sslProxyHeaders:
          "X-Forwarded-Proto": "https"

The CSP in particular was added for meshcentral, only because I have it framed in another site. Hope that helps!

@bwirt
Copy link

bwirt commented Nov 22, 2023

I believe REVERSE_PROXY needs to be set to meshcentral.example.com rather than "true". Also set REVERSE_PROXY_TLS_PORT=443. Otherwise, this worked for me. Thanks!

@silversurfer98
Copy link

Thank you @chetan, I have a similar middleware yet my devices are not finding the mesh central server even inside the network, I think I might have mis-configured something on the docker server itself, I will once again try it but again thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment