{"id":20331003,"url":"https://github.com/cans/nginx-site-manage","last_synced_at":"2026-03-08T01:09:52.906Z","repository":{"id":139898218,"uuid":"163775720","full_name":"cans/nginx-site-manage","owner":"cans","description":"Ansible role to manage nginx \"sites\" (virtual hosts configuration)","archived":false,"fork":false,"pushed_at":"2019-01-06T19:38:59.000Z","size":23,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-07T06:57:34.372Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-02T00:08:57.000Z","updated_at":"2019-01-02T00:44:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"7ec477b0-1de6-4497-a5f0-3627504a66f8","html_url":"https://github.com/cans/nginx-site-manage","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cans/nginx-site-manage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cans%2Fnginx-site-manage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cans%2Fnginx-site-manage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cans%2Fnginx-site-manage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cans%2Fnginx-site-manage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cans","download_url":"https://codeload.github.com/cans/nginx-site-manage/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cans%2Fnginx-site-manage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30240414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T00:58:18.660Z","status":"ssl_error","status_checked_at":"2026-03-08T00:55:48.608Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T20:18:27.263Z","updated_at":"2026-03-08T01:09:52.877Z","avatar_url":"https://github.com/cans.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"nginx-site-manage\n=================\n\nA Role to manage nginx \"sites\" (virtual hosts configuration).\n\nA lot of distributions allow for managing virtual hosts configuration\nvia symbolic links between a directory where configuration files are\nstored, and another from which they are loaded. One can then easily\nenable or disable a configuration by adding or removing as symlink to\nthe file in the former directory into the latter one. This is the kind\nof setup this role deals with.\n\n\n### Describing the sites to install\n\n\nEach site is describe as follows:\n\n```yaml\n- site_template: \"\u003cpath to a configuration file template\u003e\"\n  site_name: \"\u003cname of the site\u003e\"\n  site_state: \"enabled\"  # Either enabled or disabled\n  # Add any additional key/value praire your template requires\n  # here. They will be available to the template as `{{item.\u003ckey\u003e}}`\n```\n\nNote that the `site_name` will determine the name of the configuration\nfile. It should hence be valid file name.\n\nThis roles comes with a few basic templates, for simple use\ncases, you can expand on. See the example playbooks below for more.\n\nNote that, though a few templates are hereby provided, you can use\ntemplates from outside this role. Here is one way to proceed:\n\n```yaml\n- site_template: \"{{play_dir}}/templates/nginx/my-template.j2\"\n  site_name: \"my-site\"\n  site_state: \"disabled\"\n  some_extra_variable: \"this role does not care\"\n```\n\n\n### What this role doesn't do\n\nThis role does not install Nginx. It is not it's role.\n\n\nRequirements\n------------\n\nThis role has no requirements.\n\n\nRole Variables\n--------------\n\nAll variables in this role are namespaced with the prefix `nginxsites_`\n\n\n### Defaults\n\n- `nginxsites_config_dir`: nginx's configuration directory (default:\n  `/etc/nginx`)\n- `nginxsites_sites_available_dir`: directory from which nginx's loads\n  virtual hosts configuration (default:\n  `{{nginxsites_config_dir}}/sites-available`).\n- `nginxsites_sites_enabled_dir`: directory in which store virtual hosts\n  configuration (default: `{{nginxsites_config_dir}}/sites-available`).\n- `nginxsites_sites_present`: a list of site names that need to be present\n  in the `` directory. Each site is describe as explained above;\n- `nginxsites_sites_absent`: a list of sites names that must not be\n  available. Allows sites removal. (default: `[]` an empty list)\n\n\n### Template variables\n\nHere follows a description of the variables used by the _built-in_\n[templates](./templates).\n\n- `site_fqdn`: the fully qualified domain name as which \n  the site will be published (default: None must be specified)\n  Applies to templates: `proxied-site.j2`\n- `site_ip`: the IP address of the machine or container\n  actually providing the service.\n  Applies to templates: `proxied-site.j2`\n- `site_port`: the TCP port the service is bound to.\n  Applies to templates: `proxied-site.j2`\n\n\n\nDependencies\n------------\n\nThis role has no dependency.\n\n\nExample Playbook\n----------------\n\nThe following will example configure a virtual host named `hello`\nwhich proxies all request to a service running on the local host bound\nto port 8080 (cf. the `nginxsites_sites_present` variable).\n\nIt will also make sure the `default` configuration is removed (_cf._\nthe `nginxsites_sites_absent` variable).\n\n```yaml\n- hosts: servers\n  roles:\n     - role: \"cans.nginx-site-manage\"\n       nginxsites_sites_present:\n         - site_name: hello\n           site_template: \"proxied-site.j2\"  # Use built-in configuration template.\n           site_state: \"disabled\"\n           site_ip: \"127.0.0.1\"\n           site_port: 8080\n       nginxsites_sites_absent:\n         - site_name: default\n           # Site removal only cares about the `site_name'.\n           # But you could have more variables defined here.\n           # Removing an existing site is as easy as cutting\n           # its description off of the `nginxsites_sites_present` list\n           # and pasting it into the `nginxsites_sites_absent` one.\n           # Or do the converse to restore a delete site.\n```\n\nThe next example installs, at once, several sites defined in other\nroles. Here we assume the variables `service1_nginxsites_sites` and\n`service2_nginxsites_sites` are defined in the roles `service1` and\n`service2` respectively. We assume as well those variables are defined\nas explained above.\n\n```yaml\n---\n- hosts: servers\n  roles:\n\n     - role: \"service1\"\n     - role: \"service2\"\n     \n     - role: \"cans.nginx-site-manage\"\n       nginxsites_sites_present: \"{{ service1_nginxsites_sites + service2_nginxsites_sites }}\"\n\n```\nBelow is an example of how the `service1_nginxsites_sites` variable\ncould be defined in, e.g. `roles/service1/vars/main.yml`.\n```yaml\n---\nservice1_nginxsites_sites:\n- site_name: \"µservice1a\"\n  site_template: \"proxied-site.j2\"\n  site_state: \"disabled\"\n  site_ip: \"127.0.0.1\"\n  site_port: 8080\n- site_name: \"µservice1b\"\n  # Use a specific template\n  site_template: \"roles/service1/templates/nginx/µservice2.j2\"\n  site_state: \"disabled\"\n  # Define variables specific to the template.\n  service1b_root: \"/var/lib/service2/www\"\n  service1b_privatekey_file: \"/etc/ssl/private/µservice2.key\"\n  service1b_certificate_file: \"/etc/ssl/certs/µservice2.pem\"\n  # ...\n```\n\n\nLicense\n-------\n\nGPLv2\n\n\nAuthor Information\n------------------\n\nCopyright © 2018-2019, Nicolas CANIART\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcans%2Fnginx-site-manage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcans%2Fnginx-site-manage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcans%2Fnginx-site-manage/lists"}