Code Monkey home page Code Monkey logo

ansible-role-caddy's Introduction

Ansible Role: Caddy

CI

This role installs a plain caddy server on a Debian-based system and can, if you want, also place a basic reverse proxy configuration.

Requirements

N/A

Role Variables

If you only want to install Caddy, you don't need to set any variables. If you want to configure Caddy as a reverse proxy as well, you can provide an array of objects named caddy_sites with the following values:

  • additional_forwarding_ports: Allows to define a list with additional ports where Caddy should listen for this domain and forward to HTTPS.
  • allowlist: An array if IP addresses in CIDR-notation which are allowed to access this route (Optional). All other visitors receive a 404 error.
  • certificate_file: You can set this variable if you want to provide the certificate by yourself (Optional). The certificate needs permissions 0640, with root as Owner and Caddy as Group.
  • certificate_key: You can set this variable if you want to provide the certificate by yourself (Optional).
  • domain: The domain caddy should listen to.

Afterwards, you can define a list of routes composing of the following values:

  • path: Path that should be matched. Let it empty for everything or e.g. /api/* for something specific.
  • ignore_allowlist: If true the site's allowlist will not be applied to this route, thus making this route publicly available. Defaults to false.
  • reverse_proxy_destination: Where the requested should be proxied.
  • strip_prefix: If set, the matched path will be removed from the request to the destination system. This means, if somebody requests the route /api/v1/hello at the reverse proxy and you set /api/* as path, the request will be sent as /v1/hello to the destination system.

Additionally, you can also define a list of redirects composing of the following values:

  • source: Path that should be matched. Let it empty for everything or e.g. /api/* for something specific.
  • target: Target location. Becomes the response's Location header.
  • code: HTTP status code to use for the redirect. Can be an integer in the 3xx range, or 401, temporary for temporary redirect (302), permanent for a permanent redirect (301, default), html to use an HTML document to perform the redirect (will redirect browsers, but not API clients).

Certificates, domain etc. are always defined for one site and cannot be redefined for a route.

The parameter additional_template_path defines a path to a template that gets appended to a Caddy site. This option can be helpful if you generally use the options from the YAML for your configuration but have one or two routes with special requirements. The template is inserted after rendering allowlist so you can apply rewrites to your routes before the code generated by this role is applied.

Dependencies

None.

Example Playbooks

Basic installation:

---
- name: Converge
  hosts: all
  become: true

  roles:
    - role: simplificator.caddy

With reverse proxy configuration and redirects:

---
- name: Converge
  hosts: all
  become: true

  roles:
    - role: simplificator.caddy

  vars:
    caddy_sites:
      - domain: example.com
        tls_insecure: true
        routes:
          - path: ''
            reverse_proxy_destination: 192.168.50.2
            allowlist:
              - 8.8.8.8/32
        redirects:
          - source: ''
            target: '/'
        additional_forwarding_ports:
          - '8080'
          - '1337'

ansible-role-caddy's People

Contributors

andyundso avatar simplificator-renovate[bot] avatar tomcbe avatar bardocuteam avatar

Stargazers

OpenMinded avatar

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.