__/\\\_________________/\\\\\\\___________________/\\\_________________________________________________        
 _\/\\\_______________/\\\/////\\\________________\/\\\_________________________________________________       
  _\/\\\______________/\\\____\//\\\___/\\\\\\\\\__\/\\\_________________________________________________      
   _\/\\\_____________\/\\\_____\/\\\__/\\\/////\\\_\/\\\_________________/\\\\\__/\\\\\_______/\\\\\\\\__     
    _\/\\\_____________\/\\\_____\/\\\_\/\\\\\\\\\\__\/\\\\\\\\\_________/\\\///\\\\\///\\\___/\\\/////\\\_    
     _\/\\\_____________\/\\\_____\/\\\_\/\\\//////___\/\\\////\\\_______\/\\\_\//\\\__\/\\\__/\\\\\\\\\\\__   
      _\/\\\_____________\//\\\____/\\\__\/\\\_________\/\\\__\/\\\_______\/\\\__\/\\\__\/\\\_\//\\///////___  
       _\/\\\\\\\\\\\\\\\__\///\\\\\\\/___\/\\\_________\/\\\\\\\\\___/\\\_\/\\\__\/\\\__\/\\\__\//\\\\\\\\\\_ 
        _\///////////////_____\///////_____\///__________\/////////___\///__\///___\///___\///____\//////////__           
        

L0pb - Loopback

Loopback for your local development!

Why L0pb?

L0pb.me is a service that enables a loopback connection to localhost. All *.l0pb.dev and *.l0pb.me domains fundamentally point to 127.0.0.1, the localhost. This is similar to services like traefik.me or nip.io. This significantly simplifies local development, including the use of certificates.

www.l0pb.meresolves to127.0.0.1
mywebsite.l0pb.meresolves to127.0.0.1
www.l0pb.devresolves to127.0.0.1
mywebsite.l0pb.devresolves to127.0.0.1

HTTPS Support!

Thanks to Let’s Encrypt, a wildcard certificate for *.l0pb.dev and *.l0pb.me is available.

Local Development

This project is similar to the "DDEV" project but is much less demanding and complex. It is designed for simple local development. The only requirement is the l0pb-traefik image, a customized and pre-configured Traefik image.

To use L0pb locally, you must first run the following docker-compose.yml on the local environment:


services:
  traefik:
    container_name: l0pb-traefik
    hostname: l0pb-traefik
    image: psycho0verload/l0pb-traefik
    labels:
      traefik.docker.network: proxy
      traefik.enable: "true"
      traefik.http.routers.traefik.entrypoints: websecure
      traefik.http.routers.traefik.rule: Host(`traefik.l0pb.me`) || Host(`traefik.l0pb.dev`)
      traefik.http.routers.traefik.service: api@internal
      traefik.http.routers.traefik.tls: "true"
      traefik.http.services.traefik.loadbalancer.sticky.cookie.httpOnly: "true"
      traefik.http.services.traefik.loadbalancer.sticky.cookie.secure: "true"
    networks:
      proxy:
        ipv4_address: 172.30.255.254
        # Fixed IP at the end of the range of 172.30.0.0/16
        # This can also be used as a proxy address for projects
    ports:
      - mode: host
        target: 80
        published: "80"
        protocol: tcp
      - mode: host
        target: 443
        published: "443"
        protocol: tcp
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./log/traefik/:/var/log/traefik/
  mailhog:
    image: mailhog/mailhog
    hostname: l0pb-mailhog
    container_name: l0pb-mailhog
    restart: unless-stopped
    labels:
      traefik.docker.network: proxy
      traefik.enable: "true"
      traefik.http.routers.mailhog.entrypoints: websecure
      traefik.http.routers.mailhog.rule: Host(`mailhog.l0pb.me`) || Host(`mailhog.l0pb.dev`)
      traefik.http.routers.mailhog.tls: "true"
      traefik.http.routers.mailhog.service: mailhog
      traefik.http.services.mailhog.loadbalancer.server.port: "8025"
    networks:
      proxy:
networks:
  proxy:
    name: proxy
    driver: bridge
    ipam:
      config:
      - subnet: 172.30.0.0/16
    attachable: true

Place the docker-compose.yml file in a directory and then start it with the command docker compose up -d. Once the container is loaded and started, you can check whether the project basically works via https://traefik.l0pb.dev or https://traefik.l0pb.me. If the Traefik dashboard is displayed, the project is working:

Traefik is a reverse proxy that is used in this project for ports 80 and 443. These ports can each only be assigned to a single container. However, to make multiple projects available at the same time and accessible via the mentioned ports, Traefik is used. The reverse proxy binds the ports to the l0pb-traefik container. This eliminates the need to open ports in the respective projects, as this would otherwise lead to conflicts and the configuration would not work. Below is an example of using nginx.

Example


services:
  webserver:
    image: nginx
    ports:
      - "80:80"
    networks:
      default:
networks:
  default:
                        

Removing Ports


services:
  webserver:
    image: nginx
    networks:
      default:
networks:
  default:
                        

No explicit port release is generally required. It is also not necessary for databases as long as the database is in the same network as the project.

Add Labels and Network


services:
  webserver:
    image: nginx
    labels:
      traefik.docker.network: proxy
      traefik.enable: "true"
      traefik.http.routers.projectname.entrypoints: websecure
      traefik.http.routers.projectname.rule: Host(`projectname.l0pb.dev`)
      traefik.http.routers.projectname.tls: "true"
      traefik.http.routers.projectname.service: projectname
      traefik.http.services.projectname.loadbalancer.server.port: "80"
    networks:
      default:
      proxy:
networks:
  default:
  proxy:
    external: true
  • Project Name

    The placeholder projectname is replaced with the actual project name. Example:
    traefik.http.routers.my-nginx.service: my-nginx

    The project name must be unique. No other project may use the same name.

  • Domain Name

    The domain name is set under Host(`projectname.l0pb.dev`). This domain name must also be unique but can be chosen independently of the project name. The backticks ` are important.

    • Multiple Domain Names for the Same Port

      To use multiple domains for the same port, the following configuration can be used: Host(`projectname.l0pb.dev`) || Host(`projectname.l0pb.me`).

      
      traefik.docker.network: proxy
      traefik.enable: "true"
      traefik.http.routers.projectname.entrypoints: websecure
      traefik.http.routers.projectname.rule: Host(`projectname.l0pb.dev`) || Host(`projectname.l0pb.me`)
      traefik.http.routers.projectname.tls: "true"
      traefik.http.routers.projectname.service: projektname
      traefik.http.services.projectname.loadbalancer.server.port: "80"
      
    • Different Domain Names for Different Ports

      To use multiple HTTP ports for a single project, the configuration is as follows:

      
      traefik.docker.network: proxy
      traefik.enable: "true"
      traefik.http.routers.projectname.entrypoints: websecure
      traefik.http.routers.projectname.rule: Host(`projectname.l0pb.dev`)
      traefik.http.routers.projectname.tls: "true"
      traefik.http.routers.projectname.service: projectname
      traefik.http.services.projectname.loadbalancer.server.port: "80"
      
      traefik.http.routers.projectname1.entrypoints: websecure
      traefik.http.routers.projectname1.rule: Host(`projectname.l0pb.me`)
      traefik.http.routers.projectname1.tls: "true"
      traefik.http.routers.projectname1.service: projectname1
      traefik.http.services.projectname1.loadbalancer.server.port: "8080"
      

      In this configuration, the domain projectname.l0pb.dev accesses port 80, while the domain projectname.l0pb.me accesses port 8080. Both accesses are via HTTPS.

    • Further Details

      More information can be found in the official Traefik documentation

  • HTTP Port

    The HTTP port of the project is specified under traefik.http.services.projectname.loadbalancer.server.port: "80".

  • Certificate

    The certificate is provided by the reverse proxy, so the website is automatically accessed via HTTPS in the browser.

Using MailHog

MailHog is also integrated into the proxy network. This makes it accessible to all containers in the proxy network under the hostname l0pb-mailhog or in the browser at mailhog.l0pb.dev and mailhog.l0pb.me. An example usage would be: /usr/sbin/sendmail -S l0pb-mailhog:1025.

Here is an example of a local WordPress Docker environment with the L0pb project, available at https://wordpress.l0pb.dev:


services:
  wordpress:
    image: wordpress
    restart: unless-stopped
    environment:
      WORDPRESS_DB_HOST: wordpress-db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: wordpress
    volumes:
      - ./app:/var/www/html
    labels:
      traefik.docker.network: proxy
      traefik.enable: "true"
      traefik.http.routers.wordpress.entrypoints: websecure
      traefik.http.routers.wordpress.rule: Host(`wordpress.l0pb.dev`)
      traefik.http.routers.wordpress.tls: "true"
      traefik.http.routers.wordpress.service: wordpress
      traefik.http.services.wordpress.loadbalancer.server.port: "80"
    networks:
      default:
      proxy:
  wordpress-db:
    image: mariadb:10.6-focal
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: wordpress
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - ./database:/var/lib/mysql
    networks:
      default:
networks:
  proxy:
    external: true
    
    

This example shows that the database does not require a port release because wordpress and wordpress-db are in the same Docker network default. The database is accessible within this network via its hostname wordpress-db. The database exposes its normal port within the Docker network and not externally. Thus, any number of databases can be operated simultaneously.