prabhjeetme/openjanus

By prabhjeetme

Updated 4 months ago

Stack combining OpenResty, automatic SSL (registration & renewal), and a built-in WireGuard VPN.

Image
Security
Web servers
0

1.5K

prabhjeetme/openjanus repository overview

OpenJanus - All in One Nginx Server

An open-source, containerized infrastructure stack combining OpenResty, automatic SSL (registration & renewal), and a built-in WireGuard VPN to securely expose public and private endpoints with minimal configuration and operational overhead.

developed by license GitHub issues CI Repo Size GitHub stars GitHub forks

Docker Docker Pulls Docker Image Version Docker Image Size

Docker Hub

Support This Project

If you find this project helpful, consider supporting my work.

Buy Me a Coffee

Key Capabilities

  • Automatic SSL: Registration & renewal using certbot (acme-challenge)
  • Automatic VPN: WireGuard to register peers & route traffic to containers with VPN private IP.
  • OpenResty: Provides additional functionality over Nginx.
  • Nginx: All functionalities provided by Nginx.

Version Compatibility

OpenJanus VersionOpenResty VersionWireGuardCertbot
1.0.0-alpine1.27.1.2-alpine1.0.202505214.0.0

Builtin Features

  1. Preconfigured security headers in http block. These headers will be inherited in all of the server blocks. If any application requires a different value for any header, it can be overwritten in server block of itself. See Overwrite header in this example
  2. Default error pages. Container comes with predefined error pages for 30x, 40x & 50x. Error pages can be overridden in html directory.
  3. Best possible SSL & DHparam Nginx configurations (see nginx.conf).

Examples

  1. Serving custom 50x page: Configuration to serve custom 50x page here.
  2. Serving custom 403 page: Configuration to serve custom 403 page here.
  3. One line configuration to do above 2 & override all error pages here.
  4. Override default headers: This shows how to override default headers.
  5. Setting SSL: SSL setup is demonstrated in this example.
  6. Stream TCP connection: To stream TCP connection, this example should be helpful (make sure stream port is mapped to host machine).

Docker Compose

services:
  openjanus:
    image: prabhjeetme/openjanus:latest
    container_name: openjanus
    restart: always
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    environment:
      - CB_TESTING=0
      - [email protected]
      - CB_DOMAINs=example.com app1.example.com
      - WG_PEERS=phone:10.13.13.2,tablet:10.13.13.3
      - VPN_ENDPOINT=vpn.example.com
      - VPN_PORT=51820
      - SERVER_PUBLIC_IP=xx.xx.xx.xx
    ports:
      - "80:80"
      - "443:443"
      - "51820:51820/udp"
    volumes:
      - ./configs/conf:/etc/openjanus/conf:ro # Nginx config
      - ./configs/stream:/etc/openjanus/stream:ro # Nginx steam config
      - ./volumes/letsencrypt:/etc/letsencrypt # SSL certificates
      - ./volumes/openjanus/ssl:/etc/openjanus/ssl # Stores DH param
      - ./volumes/openjanus/var:/var/lib/openjanus # Stores run state
      - ./volumes/wireguard:/etc/wireguard # VPN configs
Environment Variables
Variable NameRequiredDefaultDescription
VERSIONFalse[OpenJanus version]OpenJanus version.
CB_EMAILTrueEmail required by certbot for account registration and for contacting in case of any issue.
CB_DOMAINsTrueSpace separated CB_DOMAINs that are needed to be registered (No wildcards)
CB_CRON_PATTERNFalse0 0 * * *Certbot renewal cronjob to renew due certificates.
CB_TESTINGFalse0Provide 1 (instead of 0) for test mode. Sets --staging (in case of domain challenge) & --dry-run (in case of renew).
SERVER_PUBLIC_IPTrueblankServer's public IP where container is container is deployed.
VPN_ENDPOINTTrueblankVPN Endpoint.
VPN_PORTFalse5182051820 default WireGuard port. Change if a different port is mapped on host.
SSL_DH_SIZEFalse2048DH param size. File is generated on first run
Volumes
Container PathTypeDescriptionExample
/etc/openjanus/confroNginx configurations (files containing server blocks)Reverse proxy configuration
/etc/openjanus/streamroNginx configurations (files containing server blocks)Stream TCP connection to your application
/etc/letsencryptrwStores SSL certificatesYour domain's SSL certificates
/etc/openjanus/sslrwStores DH param file-
/var/lib/openjanusrwStores OpenJanus run state (to detect first run).first_run_done
/etc/wireguardrwStores VPN configurationPeers etc
Ports
HostContainerDescription
8080HTTP port
443443HTTPs port
5182051820/udpWireGuard Port
Deployment
  1. Use docker-compose.yml as the base template.
  2. Update environment variables for your site.
  3. It is necessary to mount directories (mentioned in docker-compose.yml) for persistence.
  4. Put your nginx configs in conf & stream directory.
  5. Make sure you have created records for all DNS mentioned in CB_DOMAINs & VPN_ENDPOINT (and are propagated).
  6. Make sure VPN_PORT is allowed on firewall.
  7. Run the container using docker compose up -d.

For more information visit OpenJanus Repository on GitHub.

Tag summary

Content type

Image

Digest

sha256:5afdfae0a

Size

86.7 MB

Last updated

4 months ago

docker pull prabhjeetme/openjanus