https://github.com/morbidick/ansible-role-nginx-vhosts
Configures nginx vhosts with ansible
https://github.com/morbidick/ansible-role-nginx-vhosts
Last synced: 3 months ago
JSON representation
Configures nginx vhosts with ansible
- Host: GitHub
- URL: https://github.com/morbidick/ansible-role-nginx-vhosts
- Owner: morbidick
- Created: 2018-04-12T22:24:37.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-06T09:03:23.000Z (over 2 years ago)
- Last Synced: 2025-01-22T21:43:24.725Z (5 months ago)
- Size: 13.7 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Configure nginx vhosts with Ansible
[](https://travis-ci.org/morbidick/ansible-role-nginx-vhosts)
## Requirements
Nginx needs to be installed and configured, many vars and assumptions are tightly coupled with this [nginx role](https://github.com/morbidick/ansible-role-nginx). For Lets Encrypt support the [certbot role](https://github.com/morbidick/ansible-role-certbot) is required.
See [the full example](./webserver.md) for a complete playbook.
## Example playbook
````yaml
- hosts: all
become: yesroles:
- nginx
- nginx-vhostsvars:
nginx_vhosts:
# static host serving the files under /var/www/example.com
- host: example.com
type: static
# to proxy an upstream
- host: proxy.example.com
type: proxy # use type proxy-ws for websocket support
target: http://localhost:3000
# to proxy an upstream with dynamic IP
- host: proxy.example.com
type: proxy
dynamic_target: http://example.local:3000
# redirect to another domain
- host: redirect.example.com
type: redirect
target: https://mysite.com
# redirect to the www subdomain
- host: example2.com
type: redirect
target: www
# redirect to the domain without www
- host: www.example.com
type: redirect
target: no-www
# remove an upstream
- host: www.example.com
type: disabled
# extra_conf can be added to all types
- host: example.com
type: static
extra_conf: |
client_max_body_size 50m;
````## Role variables
None of the variables below are required.
| Variable | Default | Comment |
| :--- | :--- | :--- |For all options see [defaults/main.yml](defaults/main.yml)
## Development
You can use the [Vagrantfile](Vagrantfile) for local testing, just install vagrant and virtualbox and execute the following commands:
````bash
vagrant up
vagrant provision
````## TODO
* locations support## License
MIT